From c416aa9f08b0ff276e709df07de7a7a44baab768 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Mon, 7 Jun 2021 20:12:41 -0700 Subject: [PATCH 1/9] Initial support for module: node12 --- src/compiler/binder.ts | 2 +- src/compiler/checker.ts | 89 +++++++------ src/compiler/commandLineParser.ts | 4 +- src/compiler/diagnosticMessages.json | 16 ++- src/compiler/factory/emitHelpers.ts | 2 +- src/compiler/factory/nodeFactory.ts | 1 + src/compiler/factory/utilities.ts | 6 +- src/compiler/moduleNameResolver.ts | 21 ++- src/compiler/moduleSpecifiers.ts | 8 ++ src/compiler/program.ts | 63 ++++++++- src/compiler/transformer.ts | 3 + src/compiler/transformers/classFields.ts | 2 +- src/compiler/transformers/jsx.ts | 2 +- .../transformers/module/esnextAnd2015.ts | 122 +++++++++++++++++- src/compiler/transformers/module/module.ts | 12 +- src/compiler/transformers/module/node.ts | 84 ++++++++++++ src/compiler/tsconfig.json | 1 + src/compiler/types.ts | 38 +++++- src/compiler/utilities.ts | 44 ++++++- src/compiler/utilitiesPublic.ts | 2 +- src/compiler/watch.ts | 2 +- src/harness/compilerImpl.ts | 2 +- src/harness/harnessIO.ts | 6 +- .../codefixes/convertFunctionToEs6Class.ts | 2 +- src/services/codefixes/convertToEs6Module.ts | 2 +- .../codefixes/fixModuleAndTargetOptions.ts | 4 +- src/services/codefixes/fixSpelling.ts | 8 +- src/services/codefixes/importFixes.ts | 7 +- src/services/completions.ts | 10 +- src/services/documentRegistry.ts | 2 +- src/services/stringCompletions.ts | 6 + src/services/transpile.ts | 2 +- src/services/types.ts | 6 + src/services/utilities.ts | 2 +- .../unittests/config/commandLineParsing.ts | 2 +- .../reference/api/tsserverlibrary.d.ts | 55 +++++++- tests/baselines/reference/api/typescript.d.ts | 55 +++++++- .../awaitInNonAsyncFunction.errors.txt | 8 +- ...lpersWithLocalCollisions(module=node12).js | 27 ++++ ...ersWithLocalCollisions(module=nodenext).js | 27 ++++ ...portCallExpressionErrorInES2015.errors.txt | 12 +- ...mportCallExpressionNestedES2015.errors.txt | 8 +- ...portCallExpressionNestedES20152.errors.txt | 8 +- ...eta(module=commonjs,target=es5).errors.txt | 52 ++++---- ...(module=commonjs,target=esnext).errors.txt | 52 ++++---- .../reference/nodeModules1(module=node12).js | 58 +++++++++ .../nodeModules1(module=node12).symbols | 32 +++++ .../nodeModules1(module=node12).types | 36 ++++++ .../nodeModules1(module=nodenext).js | 58 +++++++++ .../nodeModules1(module=nodenext).symbols | 32 +++++ .../nodeModules1(module=nodenext).types | 36 ++++++ ...nodeModulesDynamicImport(module=node12).js | 39 ++++++ ...odulesDynamicImport(module=node12).symbols | 22 ++++ ...eModulesDynamicImport(module=node12).types | 26 ++++ ...deModulesDynamicImport(module=nodenext).js | 39 ++++++ ...ulesDynamicImport(module=nodenext).symbols | 22 ++++ ...odulesDynamicImport(module=nodenext).types | 26 ++++ ...xportAssignments(module=node12).errors.txt | 23 ++++ ...ModulesExportAssignments(module=node12).js | 30 +++++ ...esExportAssignments(module=node12).symbols | 16 +++ ...ulesExportAssignments(module=node12).types | 18 +++ ...ortAssignments(module=nodenext).errors.txt | 23 ++++ ...dulesExportAssignments(module=nodenext).js | 30 +++++ ...ExportAssignments(module=nodenext).symbols | 16 +++ ...esExportAssignments(module=nodenext).types | 18 +++ ...edNameCollisions(module=node12).errors.txt | 38 ++++++ ...sGeneratedNameCollisions(module=node12).js | 48 +++++++ ...ratedNameCollisions(module=node12).symbols | 38 ++++++ ...neratedNameCollisions(module=node12).types | 42 ++++++ ...NameCollisions(module=nodenext).errors.txt | 38 ++++++ ...eneratedNameCollisions(module=nodenext).js | 48 +++++++ ...tedNameCollisions(module=nodenext).symbols | 38 ++++++ ...ratedNameCollisions(module=nodenext).types | 42 ++++++ ...ModulesImportAssignments(module=node12).js | 57 ++++++++ ...esImportAssignments(module=node12).symbols | 43 ++++++ ...ulesImportAssignments(module=node12).types | 51 ++++++++ ...dulesImportAssignments(module=nodenext).js | 57 ++++++++ ...ImportAssignments(module=nodenext).symbols | 43 ++++++ ...esImportAssignments(module=nodenext).types | 51 ++++++++ ...elpersCollisions(module=node12).errors.txt | 36 ++++++ ...sImportHelpersCollisions(module=node12).js | 46 +++++++ ...rtHelpersCollisions(module=node12).symbols | 40 ++++++ ...portHelpersCollisions(module=node12).types | 48 +++++++ ...persCollisions(module=nodenext).errors.txt | 36 ++++++ ...mportHelpersCollisions(module=nodenext).js | 46 +++++++ ...HelpersCollisions(module=nodenext).symbols | 40 ++++++ ...rtHelpersCollisions(module=nodenext).types | 48 +++++++ ...lpersCollisions2(module=node12).errors.txt | 32 +++++ ...ImportHelpersCollisions2(module=node12).js | 39 ++++++ ...tHelpersCollisions2(module=node12).symbols | 22 ++++ ...ortHelpersCollisions2(module=node12).types | 22 ++++ ...ersCollisions2(module=nodenext).errors.txt | 32 +++++ ...portHelpersCollisions2(module=nodenext).js | 39 ++++++ ...elpersCollisions2(module=nodenext).symbols | 22 ++++ ...tHelpersCollisions2(module=nodenext).types | 22 ++++ ...lpersCollisions3(module=node12).errors.txt | 27 ++++ ...ImportHelpersCollisions3(module=node12).js | 38 ++++++ ...tHelpersCollisions3(module=node12).symbols | 20 +++ ...ortHelpersCollisions3(module=node12).types | 20 +++ ...ersCollisions3(module=nodenext).errors.txt | 27 ++++ ...portHelpersCollisions3(module=nodenext).js | 38 ++++++ ...elpersCollisions3(module=nodenext).symbols | 20 +++ ...tHelpersCollisions3(module=nodenext).types | 20 +++ ...odulesImportMeta(module=node12).errors.txt | 23 ++++ .../nodeModulesImportMeta(module=node12).js | 32 +++++ ...deModulesImportMeta(module=node12).symbols | 20 +++ ...nodeModulesImportMeta(module=node12).types | 24 ++++ ...ulesImportMeta(module=nodenext).errors.txt | 23 ++++ .../nodeModulesImportMeta(module=nodenext).js | 32 +++++ ...ModulesImportMeta(module=nodenext).symbols | 20 +++ ...deModulesImportMeta(module=nodenext).types | 24 ++++ ...ronousCallErrors(module=node12).errors.txt | 43 ++++++ ...lesSynchronousCallErrors(module=node12).js | 54 ++++++++ ...nchronousCallErrors(module=node12).symbols | 58 +++++++++ ...SynchronousCallErrors(module=node12).types | 68 ++++++++++ ...nousCallErrors(module=nodenext).errors.txt | 43 ++++++ ...sSynchronousCallErrors(module=nodenext).js | 54 ++++++++ ...hronousCallErrors(module=nodenext).symbols | 58 +++++++++ ...nchronousCallErrors(module=nodenext).types | 68 ++++++++++ ...lesTopLevelAwait(module=node12).errors.txt | 34 +++++ ...nodeModulesTopLevelAwait(module=node12).js | 36 ++++++ ...odulesTopLevelAwait(module=node12).symbols | 22 ++++ ...eModulesTopLevelAwait(module=node12).types | 28 ++++ ...sTopLevelAwait(module=nodenext).errors.txt | 28 ++++ ...deModulesTopLevelAwait(module=nodenext).js | 36 ++++++ ...ulesTopLevelAwait(module=nodenext).symbols | 22 ++++ ...odulesTopLevelAwait(module=nodenext).types | 28 ++++ .../parser.forAwait.es2018.errors.txt | 8 +- ....1(module=esnext,target=es2015).errors.txt | 12 +- ....1(module=system,target=es2015).errors.txt | 12 +- ...ons module-kind is out-of-range.errors.txt | 4 +- ...nd is out-of-range.oldTranspile.errors.txt | 4 +- ...s target-script is out-of-range.errors.txt | 4 +- ...pt is out-of-range.oldTranspile.errors.txt | 4 +- .../files-containing-json-file.js | 2 +- .../initial-build/include-and-files.js | 2 +- ...r-include-and-file-name-matches-ts-file.js | 2 +- ...nclude-of-json-along-with-other-include.js | 2 +- .../initial-build/include-only.js | 2 +- .../initial-build/sourcemap.js | 2 +- .../sample1/initial-build/explainFiles.js | 14 +- ...-when-host-can't-provide-terminal-width.js | 2 +- ...tatus.DiagnosticsPresent_OutputsSkipped.js | 2 +- .../jsxImportSource-option-changed.js | 2 +- ...n-Windows-style-drive-root-is-lowercase.js | 4 +- ...n-Windows-style-drive-root-is-uppercase.js | 4 +- ...ry-symlink-target-and-import-match-disk.js | 4 +- ...le-symlink-target-and-import-match-disk.js | 4 +- ...target-matches-disk-but-import-does-not.js | 4 +- ...target-matches-disk-but-import-does-not.js | 4 +- ...link-target,-and-disk-are-all-different.js | 4 +- ...link-target,-and-disk-are-all-different.js | 4 +- ...link-target-agree-but-do-not-match-disk.js | 4 +- ...link-target-agree-but-do-not-match-disk.js | 4 +- ...k-but-directory-symlink-target-does-not.js | 4 +- ...s-disk-but-file-symlink-target-does-not.js | 4 +- ...ative-information-file-location-changes.js | 4 +- ...ImportSource-option-changed-incremental.js | 4 +- .../jsxImportSource-option-changed-watch.js | 4 +- ...iles-are-reflected-in-project-structure.js | 4 +- .../handle-recreated-files-correctly.js | 8 +- .../should-reflect-change-in-config-file.js | 6 +- ...er-old-one-without-file-being-in-config.js | 2 +- ...invoked,-ask-errors-on-it-after-old-one.js | 4 +- ...re-old-one-without-file-being-in-config.js | 2 +- ...nvoked,-ask-errors-on-it-before-old-one.js | 4 +- ...er-old-one-without-file-being-in-config.js | 2 +- ...invoked,-ask-errors-on-it-after-old-one.js | 4 +- ...re-old-one-without-file-being-in-config.js | 2 +- ...nvoked,-ask-errors-on-it-before-old-one.js | 4 +- ...nging-module-name-with-different-casing.js | 2 +- ...hen-renaming-file-with-different-casing.js | 2 +- ...-generated-when-the-config-file-changes.js | 2 +- ...when-the-config-file-doesnt-have-errors.js | 2 +- ...nerated-when-the-config-file-has-errors.js | 2 +- ...-file-opened-and-config-file-has-errors.js | 2 +- ...le-opened-and-doesnt-contain-any-errors.js | 2 +- ...rs-but-suppressDiagnosticEvents-is-true.js | 2 +- ...s-contains-the-project-reference-errors.js | 2 +- ...-same-ambient-module-and-is-also-module.js | 2 +- ...project-structure-and-reports-no-errors.js | 2 +- ...-when-timeout-occurs-after-installation.js | 4 +- ...n-timeout-occurs-inbetween-installation.js | 4 +- ...hen-json-is-root-file-found-by-tsconfig.js | 2 +- ...json-is-not-root-file-found-by-tsconfig.js | 2 +- ...-global-error-gerErr-with-sync-commands.js | 2 +- ...or-returns-includes-global-error-getErr.js | 2 +- ...-includes-global-error-geterrForProject.js | 2 +- ...large-file-size-is-determined-correctly.js | 2 +- ...t-is-not-open-gerErr-with-sync-commands.js | 2 +- ...n-dependency-project-is-not-open-getErr.js | 2 +- ...cy-project-is-not-open-geterrForProject.js | 2 +- ...-file-is-open-gerErr-with-sync-commands.js | 4 +- ...-when-the-depedency-file-is-open-getErr.js | 4 +- ...depedency-file-is-open-geterrForProject.js | 4 +- ...t-is-not-open-gerErr-with-sync-commands.js | 2 +- ...n-dependency-project-is-not-open-getErr.js | 2 +- ...cy-project-is-not-open-geterrForProject.js | 2 +- ...-file-is-open-gerErr-with-sync-commands.js | 4 +- ...-when-the-depedency-file-is-open-getErr.js | 4 +- ...depedency-file-is-open-geterrForProject.js | 4 +- .../ancestor-and-project-ref-management.js | 12 +- ...disableSourceOfProjectReferenceRedirect.js | 2 +- ...port-with-referenced-project-when-built.js | 2 +- .../auto-import-with-referenced-project.js | 2 +- ...ssfully-find-references-with-out-option.js | 6 +- ...indirect-project-but-not-in-another-one.js | 6 +- ...dProjectLoad-is-set-in-indirect-project.js | 6 +- ...oes-not-error-on-container-only-project.js | 6 +- .../sibling-projects.js | 4 +- ...solution-is-built-with-preserveSymlinks.js | 2 +- ...-and-has-index.ts-and-solution-is-built.js | 2 +- ...tion-is-not-built-with-preserveSymlinks.js | 2 +- ...-has-index.ts-and-solution-is-not-built.js | 2 +- ...solution-is-built-with-preserveSymlinks.js | 2 +- ...th-scoped-package-and-solution-is-built.js | 2 +- ...tion-is-not-built-with-preserveSymlinks.js | 2 +- ...coped-package-and-solution-is-not-built.js | 2 +- ...solution-is-built-with-preserveSymlinks.js | 2 +- ...le-from-subFolder-and-solution-is-built.js | 2 +- ...tion-is-not-built-with-preserveSymlinks.js | 2 +- ...rom-subFolder-and-solution-is-not-built.js | 2 +- ...solution-is-built-with-preserveSymlinks.js | 2 +- ...th-scoped-package-and-solution-is-built.js | 2 +- ...tion-is-not-built-with-preserveSymlinks.js | 2 +- ...coped-package-and-solution-is-not-built.js | 2 +- ...disableSourceOfProjectReferenceRedirect.js | 8 +- ...ect-when-referenced-project-is-not-open.js | 4 +- ...disableSourceOfProjectReferenceRedirect.js | 12 +- ...project-when-referenced-project-is-open.js | 8 +- ...ject-is-directly-referenced-by-solution.js | 12 +- ...ct-is-indirectly-referenced-by-solution.js | 24 ++-- ...nced-project-and-using-declaration-maps.js | 4 +- ...ot-file-is-file-from-referenced-project.js | 4 +- ...indirect-project-but-not-in-another-one.js | 12 +- ...dProjectLoad-is-set-in-indirect-project.js | 12 +- ...-if-disableReferencedProjectLoad-is-set.js | 6 +- ...ces-open-file-through-project-reference.js | 22 ++-- ...ct-is-indirectly-referenced-by-solution.js | 34 ++--- ...nction-as-object-literal-property-types.js | 6 +- ...row-function-as-object-literal-property.js | 4 +- ...ss-when-using-arrow-function-assignment.js | 6 +- ...s-when-using-method-of-class-expression.js | 6 +- ...ness-when-using-object-literal-property.js | 6 +- ...cts-are-open-and-one-project-references.js | 16 +-- ...ts-have-allowJs-and-emitDeclarationOnly.js | 2 +- ...ng-solution-and-siblings-are-not-loaded.js | 2 +- ...getting-project-from-orphan-script-info.js | 2 +- ...directory-watch-invoke-on-file-creation.js | 8 +- ...tion-when-project-compiles-from-sources.js | 4 +- ...s-in-typings-folder-and-then-recompiles.js | 2 +- ...mpiles-after-deleting-generated-folders.js | 4 +- ...ping-when-project-compiles-from-sources.js | 4 +- ...s-in-typings-folder-and-then-recompiles.js | 4 +- ...mpiles-after-deleting-generated-folders.js | 6 +- ...name-in-common-file-renames-all-project.js | 4 +- tests/cases/conformance/node/nodeModules1.ts | 34 +++++ .../node/nodeModulesDynamicImport.ts | 23 ++++ .../node/nodeModulesExportAssignments.ts | 19 +++ .../nodeModulesGeneratedNameCollisions.ts | 25 ++++ .../node/nodeModulesImportAssignments.ts | 30 +++++ .../nodeModulesImportHelpersCollisions.ts | 30 +++++ .../nodeModulesImportHelpersCollisions2.ts | 26 ++++ .../nodeModulesImportHelpersCollisions3.ts | 24 ++++ .../conformance/node/nodeModulesImportMeta.ts | 19 +++ .../node/nodeModulesSynchronousCallErrors.ts | 33 +++++ .../node/nodeModulesTopLevelAwait.ts | 21 +++ 267 files changed, 4178 insertions(+), 473 deletions(-) create mode 100644 src/compiler/transformers/module/node.ts create mode 100644 tests/baselines/reference/emitHelpersWithLocalCollisions(module=node12).js create mode 100644 tests/baselines/reference/emitHelpersWithLocalCollisions(module=nodenext).js create mode 100644 tests/baselines/reference/nodeModules1(module=node12).js create mode 100644 tests/baselines/reference/nodeModules1(module=node12).symbols create mode 100644 tests/baselines/reference/nodeModules1(module=node12).types create mode 100644 tests/baselines/reference/nodeModules1(module=nodenext).js create mode 100644 tests/baselines/reference/nodeModules1(module=nodenext).symbols create mode 100644 tests/baselines/reference/nodeModules1(module=nodenext).types create mode 100644 tests/baselines/reference/nodeModulesDynamicImport(module=node12).js create mode 100644 tests/baselines/reference/nodeModulesDynamicImport(module=node12).symbols create mode 100644 tests/baselines/reference/nodeModulesDynamicImport(module=node12).types create mode 100644 tests/baselines/reference/nodeModulesDynamicImport(module=nodenext).js create mode 100644 tests/baselines/reference/nodeModulesDynamicImport(module=nodenext).symbols create mode 100644 tests/baselines/reference/nodeModulesDynamicImport(module=nodenext).types create mode 100644 tests/baselines/reference/nodeModulesExportAssignments(module=node12).errors.txt create mode 100644 tests/baselines/reference/nodeModulesExportAssignments(module=node12).js create mode 100644 tests/baselines/reference/nodeModulesExportAssignments(module=node12).symbols create mode 100644 tests/baselines/reference/nodeModulesExportAssignments(module=node12).types create mode 100644 tests/baselines/reference/nodeModulesExportAssignments(module=nodenext).errors.txt create mode 100644 tests/baselines/reference/nodeModulesExportAssignments(module=nodenext).js create mode 100644 tests/baselines/reference/nodeModulesExportAssignments(module=nodenext).symbols create mode 100644 tests/baselines/reference/nodeModulesExportAssignments(module=nodenext).types create mode 100644 tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=node12).errors.txt create mode 100644 tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=node12).js create mode 100644 tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=node12).symbols create mode 100644 tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=node12).types create mode 100644 tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=nodenext).errors.txt create mode 100644 tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=nodenext).js create mode 100644 tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=nodenext).symbols create mode 100644 tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=nodenext).types create mode 100644 tests/baselines/reference/nodeModulesImportAssignments(module=node12).js create mode 100644 tests/baselines/reference/nodeModulesImportAssignments(module=node12).symbols create mode 100644 tests/baselines/reference/nodeModulesImportAssignments(module=node12).types create mode 100644 tests/baselines/reference/nodeModulesImportAssignments(module=nodenext).js create mode 100644 tests/baselines/reference/nodeModulesImportAssignments(module=nodenext).symbols create mode 100644 tests/baselines/reference/nodeModulesImportAssignments(module=nodenext).types create mode 100644 tests/baselines/reference/nodeModulesImportHelpersCollisions(module=node12).errors.txt create mode 100644 tests/baselines/reference/nodeModulesImportHelpersCollisions(module=node12).js create mode 100644 tests/baselines/reference/nodeModulesImportHelpersCollisions(module=node12).symbols create mode 100644 tests/baselines/reference/nodeModulesImportHelpersCollisions(module=node12).types create mode 100644 tests/baselines/reference/nodeModulesImportHelpersCollisions(module=nodenext).errors.txt create mode 100644 tests/baselines/reference/nodeModulesImportHelpersCollisions(module=nodenext).js create mode 100644 tests/baselines/reference/nodeModulesImportHelpersCollisions(module=nodenext).symbols create mode 100644 tests/baselines/reference/nodeModulesImportHelpersCollisions(module=nodenext).types create mode 100644 tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=node12).errors.txt create mode 100644 tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=node12).js create mode 100644 tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=node12).symbols create mode 100644 tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=node12).types create mode 100644 tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=nodenext).errors.txt create mode 100644 tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=nodenext).js create mode 100644 tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=nodenext).symbols create mode 100644 tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=nodenext).types create mode 100644 tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=node12).errors.txt create mode 100644 tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=node12).js create mode 100644 tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=node12).symbols create mode 100644 tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=node12).types create mode 100644 tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=nodenext).errors.txt create mode 100644 tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=nodenext).js create mode 100644 tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=nodenext).symbols create mode 100644 tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=nodenext).types create mode 100644 tests/baselines/reference/nodeModulesImportMeta(module=node12).errors.txt create mode 100644 tests/baselines/reference/nodeModulesImportMeta(module=node12).js create mode 100644 tests/baselines/reference/nodeModulesImportMeta(module=node12).symbols create mode 100644 tests/baselines/reference/nodeModulesImportMeta(module=node12).types create mode 100644 tests/baselines/reference/nodeModulesImportMeta(module=nodenext).errors.txt create mode 100644 tests/baselines/reference/nodeModulesImportMeta(module=nodenext).js create mode 100644 tests/baselines/reference/nodeModulesImportMeta(module=nodenext).symbols create mode 100644 tests/baselines/reference/nodeModulesImportMeta(module=nodenext).types create mode 100644 tests/baselines/reference/nodeModulesSynchronousCallErrors(module=node12).errors.txt create mode 100644 tests/baselines/reference/nodeModulesSynchronousCallErrors(module=node12).js create mode 100644 tests/baselines/reference/nodeModulesSynchronousCallErrors(module=node12).symbols create mode 100644 tests/baselines/reference/nodeModulesSynchronousCallErrors(module=node12).types create mode 100644 tests/baselines/reference/nodeModulesSynchronousCallErrors(module=nodenext).errors.txt create mode 100644 tests/baselines/reference/nodeModulesSynchronousCallErrors(module=nodenext).js create mode 100644 tests/baselines/reference/nodeModulesSynchronousCallErrors(module=nodenext).symbols create mode 100644 tests/baselines/reference/nodeModulesSynchronousCallErrors(module=nodenext).types create mode 100644 tests/baselines/reference/nodeModulesTopLevelAwait(module=node12).errors.txt create mode 100644 tests/baselines/reference/nodeModulesTopLevelAwait(module=node12).js create mode 100644 tests/baselines/reference/nodeModulesTopLevelAwait(module=node12).symbols create mode 100644 tests/baselines/reference/nodeModulesTopLevelAwait(module=node12).types create mode 100644 tests/baselines/reference/nodeModulesTopLevelAwait(module=nodenext).errors.txt create mode 100644 tests/baselines/reference/nodeModulesTopLevelAwait(module=nodenext).js create mode 100644 tests/baselines/reference/nodeModulesTopLevelAwait(module=nodenext).symbols create mode 100644 tests/baselines/reference/nodeModulesTopLevelAwait(module=nodenext).types create mode 100644 tests/cases/conformance/node/nodeModules1.ts create mode 100644 tests/cases/conformance/node/nodeModulesDynamicImport.ts create mode 100644 tests/cases/conformance/node/nodeModulesExportAssignments.ts create mode 100644 tests/cases/conformance/node/nodeModulesGeneratedNameCollisions.ts create mode 100644 tests/cases/conformance/node/nodeModulesImportAssignments.ts create mode 100644 tests/cases/conformance/node/nodeModulesImportHelpersCollisions.ts create mode 100644 tests/cases/conformance/node/nodeModulesImportHelpersCollisions2.ts create mode 100644 tests/cases/conformance/node/nodeModulesImportHelpersCollisions3.ts create mode 100644 tests/cases/conformance/node/nodeModulesImportMeta.ts create mode 100644 tests/cases/conformance/node/nodeModulesSynchronousCallErrors.ts create mode 100644 tests/cases/conformance/node/nodeModulesTopLevelAwait.ts diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index faefba86582f1..2152f3ec957f7 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -2374,7 +2374,7 @@ namespace ts { function checkStrictModeLabeledStatement(node: LabeledStatement) { // Grammar checking for labeledStatement - if (inStrictMode && options.target! >= ScriptTarget.ES2015) { + if (inStrictMode && getEmitScriptTarget(options) >= ScriptTarget.ES2015) { if (isDeclarationStatement(node.statement) || isVariableStatement(node.statement)) { errorOnFirstToken(node.label, Diagnostics.A_label_is_not_allowed_here); } diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f5f458a560573..9b8cce1ccc148 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1508,7 +1508,7 @@ namespace ts { } else if (isParameterPropertyDeclaration(declaration, declaration.parent)) { // foo = this.bar is illegal in esnext+useDefineForClassFields when bar is a parameter property - return !(compilerOptions.target === ScriptTarget.ESNext && useDefineForClassFields + return !(getEmitScriptTarget(compilerOptions) === ScriptTarget.ESNext && useDefineForClassFields && getContainingClass(declaration) === getContainingClass(usage) && isUsedInFunctionOrInstanceProperty(usage, declaration)); } @@ -1539,7 +1539,7 @@ namespace ts { return true; } if (isUsedInFunctionOrInstanceProperty(usage, declaration)) { - if (compilerOptions.target === ScriptTarget.ESNext && useDefineForClassFields + if (getEmitScriptTarget(compilerOptions) === ScriptTarget.ESNext && useDefineForClassFields && getContainingClass(declaration) && (isPropertyDeclaration(declaration) || isParameterPropertyDeclaration(declaration, declaration.parent))) { return !isPropertyImmediatelyReferencedWithinDeclaration(declaration, usage, /*stopAtAnyPropertyDeclaration*/ true); @@ -1943,7 +1943,7 @@ namespace ts { case SyntaxKind.ArrowFunction: // when targeting ES6 or higher there is no 'arguments' in an arrow function // for lower compile targets the resolved symbol is used to emit an error - if (compilerOptions.target! >= ScriptTarget.ES2015) { + if (getEmitScriptTarget(compilerOptions) >= ScriptTarget.ES2015) { break; } // falls through @@ -2121,7 +2121,7 @@ namespace ts { // Perform extra checks only if error reporting was requested if (nameNotFoundMessage) { - if (propertyWithInvalidInitializer && !(compilerOptions.target === ScriptTarget.ESNext && useDefineForClassFields)) { + if (propertyWithInvalidInitializer && !(getEmitScriptTarget(compilerOptions) === ScriptTarget.ESNext && useDefineForClassFields)) { // We have a match, but the reference occurred within a property initializer and the identifier also binds // to a local variable in the constructor where the code will be emitted. Note that this is actually allowed // with ESNext+useDefineForClassFields because the scope semantics are different. @@ -2762,7 +2762,7 @@ namespace ts { if (!isIdentifier(name)) { return undefined; } - const suppressInteropError = name.escapedText === InternalSymbolName.Default && !!(compilerOptions.allowSyntheticDefaultImports || compilerOptions.esModuleInterop); + const suppressInteropError = name.escapedText === InternalSymbolName.Default && !!(compilerOptions.allowSyntheticDefaultImports || getESModuleInterop(compilerOptions)); const targetSymbol = resolveESModuleSymbol(moduleSymbol, moduleSpecifier, /*dontResolveAlias*/ false, suppressInteropError); if (targetSymbol) { if (name.escapedText) { @@ -2851,18 +2851,18 @@ namespace ts { function reportInvalidImportEqualsExportMember(node: ImportDeclaration | ExportDeclaration | VariableDeclaration, name: Identifier, declarationName: string, moduleName: string) { if (moduleKind >= ModuleKind.ES2015) { - const message = compilerOptions.esModuleInterop ? Diagnostics._0_can_only_be_imported_by_using_a_default_import : + const message = getESModuleInterop(compilerOptions) ? Diagnostics._0_can_only_be_imported_by_using_a_default_import : Diagnostics._0_can_only_be_imported_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import; error(name, message, declarationName); } else { if (isInJSFile(node)) { - const message = compilerOptions.esModuleInterop ? Diagnostics._0_can_only_be_imported_by_using_a_require_call_or_by_using_a_default_import : + const message = getESModuleInterop(compilerOptions) ? Diagnostics._0_can_only_be_imported_by_using_a_require_call_or_by_using_a_default_import : Diagnostics._0_can_only_be_imported_by_using_a_require_call_or_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import; error(name, message, declarationName); } else { - const message = compilerOptions.esModuleInterop ? Diagnostics._0_can_only_be_imported_by_using_import_1_require_2_or_a_default_import : + const message = getESModuleInterop(compilerOptions) ? Diagnostics._0_can_only_be_imported_by_using_import_1_require_2_or_a_default_import : Diagnostics._0_can_only_be_imported_by_using_import_1_require_2_or_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import; error(name, message, declarationName, declarationName, moduleName); } @@ -3324,6 +3324,12 @@ namespace ts { if (resolvedModule.isExternalLibraryImport && !resolutionExtensionIsTSOrJson(resolvedModule.extension)) { errorOnImplicitAnyModule(/*isError*/ false, errorNode, resolvedModule, moduleReference); } + if (getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Node12 || getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.NodeNext) { + const isSyncImport = (currentSourceFile.impliedNodeFormat === ModuleKind.CommonJS && !findAncestor(location, isImportCall)) || !!findAncestor(location, isImportEqualsDeclaration); + if (isSyncImport && sourceFile.impliedNodeFormat === ModuleKind.ESNext) { + error(errorNode, Diagnostics.Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_es_module_which_cannot_be_imported_synchronously_Use_dynamic_import_instead, moduleReference); + } + } // merged symbol is module declaration symbol combined with all augmentations return getMergedSymbol(sourceFile.symbol); } @@ -3385,7 +3391,6 @@ namespace ts { * Direct users to import source with .js extension if outputting an ES module. * @see https://github.com/microsoft/TypeScript/issues/42151 */ - const moduleKind = getEmitModuleKind(compilerOptions); if (moduleKind >= ModuleKind.ES2015) { replacedImportSource += ".js"; } @@ -3393,7 +3398,7 @@ namespace ts { } else if (!compilerOptions.resolveJsonModule && fileExtensionIs(moduleReference, Extension.Json) && - getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.NodeJs && + getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.Classic && hasJsonModuleEmitEnabled(compilerOptions)) { error(errorNode, Diagnostics.Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension, moduleReference); } @@ -3477,7 +3482,7 @@ namespace ts { return symbol; } - if (compilerOptions.esModuleInterop) { + if (getESModuleInterop(compilerOptions)) { const referenceParent = referencingLocation.parent; if ( (isImportDeclaration(referenceParent) && getNamespaceDeclarationNode(referenceParent)) || @@ -5771,7 +5776,7 @@ namespace ts { const nonRootParts = chain.length > 1 ? createAccessFromSymbolChain(chain, chain.length - 1, 1) : undefined; const typeParameterNodes = overrideTypeArguments || lookupTypeParameterNodes(chain, 0, context); const specifier = getSpecifierForModuleSymbol(chain[0], context); - if (!(context.flags & NodeBuilderFlags.AllowNodeModulesRelativePaths) && getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.NodeJs && specifier.indexOf("/node_modules/") >= 0) { + if (!(context.flags & NodeBuilderFlags.AllowNodeModulesRelativePaths) && getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.Classic && specifier.indexOf("/node_modules/") >= 0) { // If ultimately we can only name the symbol with a reference that dives into a `node_modules` folder, we should error // since declaration files with these kinds of references are liable to fail when published :( context.encounteredError = true; @@ -6020,7 +6025,7 @@ namespace ts { if (nameType) { if (nameType.flags & TypeFlags.StringOrNumberLiteral) { const name = "" + (nameType as StringLiteralType | NumberLiteralType).value; - if (!isIdentifierText(name, compilerOptions.target) && !isNumericLiteralName(name)) { + if (!isIdentifierText(name, getEmitScriptTarget(compilerOptions)) && !isNumericLiteralName(name)) { return factory.createStringLiteral(name, !!singleQuote); } if (isNumericLiteralName(name) && startsWith(name, "-")) { @@ -6035,7 +6040,7 @@ namespace ts { } function createPropertyNameNodeForIdentifierOrLiteral(name: string, stringNamed?: boolean, singleQuote?: boolean) { - return isIdentifierText(name, compilerOptions.target) ? factory.createIdentifier(name) : + return isIdentifierText(name, getEmitScriptTarget(compilerOptions)) ? factory.createIdentifier(name) : !stringNamed && isNumericLiteralName(name) && +name >= 0 ? factory.createNumericLiteral(+name) : factory.createStringLiteral(name, !!singleQuote); } @@ -7148,7 +7153,7 @@ namespace ts { return; } let verbatimTargetName = unescapeLeadingUnderscores(target.escapedName); - if (verbatimTargetName === InternalSymbolName.ExportEquals && (compilerOptions.esModuleInterop || compilerOptions.allowSyntheticDefaultImports)) { + if (verbatimTargetName === InternalSymbolName.ExportEquals && (getESModuleInterop(compilerOptions) || compilerOptions.allowSyntheticDefaultImports)) { // target refers to an `export=` symbol that was hoisted into a synthetic default - rename here to match verbatimTargetName = InternalSymbolName.Default; } @@ -7833,7 +7838,7 @@ namespace ts { if (nameType) { if (nameType.flags & TypeFlags.StringOrNumberLiteral) { const name = "" + (nameType as StringLiteralType | NumberLiteralType).value; - if (!isIdentifierText(name, compilerOptions.target) && !isNumericLiteralName(name)) { + if (!isIdentifierText(name, getEmitScriptTarget(compilerOptions)) && !isNumericLiteralName(name)) { return `"${escapeString(name, CharacterCodes.doubleQuote)}"`; } if (isNumericLiteralName(name) && startsWith(name, "-")) { @@ -17522,7 +17527,7 @@ namespace ts { path = `${str}`; } // Otherwise write a dotted name if possible - else if (isIdentifierText(str, compilerOptions.target)) { + else if (isIdentifierText(str, getEmitScriptTarget(compilerOptions))) { path = `${path}.${str}`; } // Failing that, check if the name is already a computed name @@ -27514,7 +27519,7 @@ namespace ts { grammarErrorOnNode(right, Diagnostics.Cannot_assign_to_private_method_0_Private_methods_are_not_writable, idText(right)); } - if (lexicallyScopedSymbol?.valueDeclaration && (compilerOptions.target === ScriptTarget.ESNext && !useDefineForClassFields)) { + if (lexicallyScopedSymbol?.valueDeclaration && (getEmitScriptTarget(compilerOptions) === ScriptTarget.ESNext && !useDefineForClassFields)) { const lexicalClass = getContainingClass(lexicallyScopedSymbol.valueDeclaration); const parentStaticFieldInitializer = findAncestor(node, (n) => { if (n === lexicalClass) return "quit"; @@ -30457,7 +30462,14 @@ namespace ts { function checkImportMetaProperty(node: MetaProperty) { if (moduleKind !== ModuleKind.ES2020 && moduleKind !== ModuleKind.ESNext && moduleKind !== ModuleKind.System) { - error(node, Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_esnext_or_system); + if (moduleKind === ModuleKind.Node12 || moduleKind === ModuleKind.NodeNext) { + if (getSourceFileOfNode(node).impliedNodeFormat !== ModuleKind.ESNext) { + error(node, Diagnostics.The_import_meta_meta_property_is_not_allowed_in_files_which_will_build_into_CommonJS_output); + } + } + else { + error(node, Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_esnext_system_node12_or_nodenext); + } } const file = getSourceFileOfNode(node); Debug.assert(!!(file.flags & NodeFlags.PossiblyContainsImportMeta), "Containing file is missing import meta node flag."); @@ -31466,10 +31478,10 @@ namespace ts { Diagnostics.await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module); diagnostics.add(diagnostic); } - if ((moduleKind !== ModuleKind.ESNext && moduleKind !== ModuleKind.System) || languageVersion < ScriptTarget.ES2017) { + if ((moduleKind !== ModuleKind.ESNext && moduleKind !== ModuleKind.System && !(moduleKind === ModuleKind.NodeNext && getSourceFileOfNode(node).impliedNodeFormat === ModuleKind.ESNext)) || languageVersion < ScriptTarget.ES2017) { span = getSpanOfTokenAtPosition(sourceFile, node.pos); const diagnostic = createFileDiagnostic(sourceFile, span.start, span.length, - Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_the_target_option_is_set_to_es2017_or_higher); + Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher); diagnostics.add(diagnostic); } } @@ -33699,7 +33711,7 @@ namespace ts { // - The constructor declares parameter properties // or the containing class declares instance member variables with initializers. const superCallShouldBeFirst = - (compilerOptions.target !== ScriptTarget.ESNext || !useDefineForClassFields) && + (getEmitScriptTarget(compilerOptions) !== ScriptTarget.ESNext || !useDefineForClassFields) && (some((node.parent as ClassDeclaration).members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) || some(node.parameters, p => hasSyntacticModifier(p, ModifierFlags.ParameterPropertyModifier))); @@ -35563,7 +35575,7 @@ namespace ts { function checkCollisionWithRequireExportsInGeneratedCode(node: Node, name: Identifier | undefined) { // No need to check for require or exports for ES6 modules and later - if (moduleKind >= ModuleKind.ES2015) { + if (moduleKind >= ModuleKind.ES2015 && !(moduleKind >= ModuleKind.Node12 && getSourceFileOfNode(node).impliedNodeFormat === ModuleKind.CommonJS)) { return; } @@ -37301,8 +37313,8 @@ namespace ts { * The name cannot be used as 'Object' of user defined types with special target. */ function checkClassNameCollisionWithObject(name: Identifier): void { - if (languageVersion === ScriptTarget.ES5 && name.escapedText === "Object" - && moduleKind < ModuleKind.ES2015) { + if (languageVersion >= ScriptTarget.ES5 && name.escapedText === "Object" + && (moduleKind < ModuleKind.ES2015 || getSourceFileOfNode(name).impliedNodeFormat === ModuleKind.CommonJS)) { error(name, Diagnostics.Class_name_cannot_be_Object_when_targeting_ES5_with_module_0, ModuleKind[moduleKind]); // https://github.com/Microsoft/TypeScript/issues/17494 } } @@ -38508,8 +38520,8 @@ namespace ts { checkAliasSymbol(node); if (node.kind === SyntaxKind.ImportSpecifier && idText(node.propertyName || node.name) === "default" && - compilerOptions.esModuleInterop && - moduleKind !== ModuleKind.System && moduleKind < ModuleKind.ES2015) { + getESModuleInterop(compilerOptions) && + moduleKind !== ModuleKind.System && (moduleKind < ModuleKind.ES2015 || getSourceFileOfNode(node).impliedNodeFormat === ModuleKind.CommonJS)) { checkExternalEmitHelpers(node, ExternalEmitHelpers.ImportDefault); } } @@ -38531,7 +38543,7 @@ namespace ts { if (importClause.namedBindings) { if (importClause.namedBindings.kind === SyntaxKind.NamespaceImport) { checkImportBinding(importClause.namedBindings); - if (moduleKind !== ModuleKind.System && moduleKind < ModuleKind.ES2015 && compilerOptions.esModuleInterop) { + if (moduleKind !== ModuleKind.System && (moduleKind < ModuleKind.ES2015 || getSourceFileOfNode(node).impliedNodeFormat === ModuleKind.CommonJS) && getESModuleInterop(compilerOptions)) { // import * as ns from "foo"; checkExternalEmitHelpers(node, ExternalEmitHelpers.ImportStar); } @@ -38579,7 +38591,7 @@ namespace ts { } } else { - if (moduleKind >= ModuleKind.ES2015 && !node.isTypeOnly && !(node.flags & NodeFlags.Ambient)) { + if (moduleKind >= ModuleKind.ES2015 && getSourceFileOfNode(node).impliedNodeFormat === undefined && !node.isTypeOnly && !(node.flags & NodeFlags.Ambient)) { // Import equals declaration is deprecated in es6 or above grammarErrorOnNode(node, Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); } @@ -38624,12 +38636,12 @@ namespace ts { else if (node.exportClause) { checkAliasSymbol(node.exportClause); } - if (moduleKind !== ModuleKind.System && moduleKind < ModuleKind.ES2015) { + if (moduleKind !== ModuleKind.System && (moduleKind < ModuleKind.ES2015 || getSourceFileOfNode(node).impliedNodeFormat === ModuleKind.CommonJS)) { if (node.exportClause) { // export * as ns from "foo"; // For ES2015 modules, we emit it as a pair of `import * as a_1 ...; export { a_1 as ns }` and don't need the helper. // We only use the helper here when in esModuleInterop - if (compilerOptions.esModuleInterop) { + if (getESModuleInterop(compilerOptions)) { checkExternalEmitHelpers(node, ExternalEmitHelpers.ImportStar); } } @@ -38720,9 +38732,9 @@ namespace ts { } } else { - if (compilerOptions.esModuleInterop && + if (getESModuleInterop(compilerOptions) && moduleKind !== ModuleKind.System && - moduleKind < ModuleKind.ES2015 && + (moduleKind < ModuleKind.ES2015 || getSourceFileOfNode(node).impliedNodeFormat === ModuleKind.CommonJS) && idText(node.propertyName || node.name) === "default") { checkExternalEmitHelpers(node, ExternalEmitHelpers.ImportDefault); } @@ -38785,7 +38797,7 @@ namespace ts { } if (node.isExportEquals && !(node.flags & NodeFlags.Ambient)) { - if (moduleKind >= ModuleKind.ES2015) { + if (moduleKind >= ModuleKind.ES2015 && getSourceFileOfNode(node).impliedNodeFormat !== ModuleKind.CommonJS) { // export assignment is not supported in es6 modules grammarErrorOnNode(node, Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead); } @@ -41883,9 +41895,9 @@ namespace ts { diagnostics.add(createDiagnosticForNode(forInOrOfStatement.awaitModifier, Diagnostics.for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module)); } - if ((moduleKind !== ModuleKind.ESNext && moduleKind !== ModuleKind.System) || languageVersion < ScriptTarget.ES2017) { + if ((moduleKind !== ModuleKind.ESNext && moduleKind !== ModuleKind.System && !(moduleKind === ModuleKind.NodeNext && getSourceFileOfNode(forInOrOfStatement).impliedNodeFormat === ModuleKind.ESNext)) || languageVersion < ScriptTarget.ES2017) { diagnostics.add(createDiagnosticForNode(forInOrOfStatement.awaitModifier, - Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_the_target_option_is_set_to_es2017_or_higher)); + Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher)); } } } @@ -42264,8 +42276,7 @@ namespace ts { return grammarErrorOnNode(node.exclamationToken, message); } - const moduleKind = getEmitModuleKind(compilerOptions); - if (moduleKind < ModuleKind.ES2015 && moduleKind !== ModuleKind.System && + if ((moduleKind < ModuleKind.ES2015 || getSourceFileOfNode(node).impliedNodeFormat === ModuleKind.CommonJS) && moduleKind !== ModuleKind.System && !(node.parent.parent.flags & NodeFlags.Ambient) && hasSyntacticModifier(node.parent.parent, ModifierFlags.Export)) { checkESModuleMarker(node.name); } @@ -42635,7 +42646,7 @@ namespace ts { function checkGrammarImportCallExpression(node: ImportCall): boolean { if (moduleKind === ModuleKind.ES2015) { - return grammarErrorOnNode(node, Diagnostics.Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_esnext_commonjs_amd_system_or_umd); + return grammarErrorOnNode(node, Diagnostics.Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_esnext_commonjs_amd_system_umd_node12_or_nodenext); } if (node.typeArguments) { diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 09107e83df8f8..49a0b71fdbe99 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -393,7 +393,9 @@ namespace ts { es6: ModuleKind.ES2015, es2015: ModuleKind.ES2015, es2020: ModuleKind.ES2020, - esnext: ModuleKind.ESNext + esnext: ModuleKind.ESNext, + node12: ModuleKind.Node12, + nodenext: ModuleKind.NodeNext, })), affectsModuleResolution: true, affectsEmit: true, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index b71edb82c4bd0..a199dab5bb579 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -944,7 +944,7 @@ "category": "Error", "code": 1322 }, - "Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'.": { + "Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'.": { "category": "Error", "code": 1323 }, @@ -1016,7 +1016,7 @@ "category": "Error", "code": 1342 }, - "The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'.": { + "The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'.": { "category": "Error", "code": 1343 }, @@ -1144,7 +1144,7 @@ "category": "Message", "code": 1377 }, - "Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher.": { + "Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher.": { "category": "Error", "code": 1378 }, @@ -1360,7 +1360,7 @@ "category": "Error", "code": 1431 }, - "Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher.": { + "Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher.": { "category": "Error", "code": 1432 }, @@ -1368,6 +1368,14 @@ "category": "Error", "code": 1433 }, + "The 'import.meta' meta-property is not allowed in files which will build into CommonJS output.": { + "category": "Error", + "code": 1434 + }, + "Module '{0}' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead.": { + "category": "Error", + "code": 1435 + }, "The types of '{0}' are incompatible between these types.": { "category": "Error", diff --git a/src/compiler/factory/emitHelpers.ts b/src/compiler/factory/emitHelpers.ts index a6ef294c76d4b..b205818d4e883 100644 --- a/src/compiler/factory/emitHelpers.ts +++ b/src/compiler/factory/emitHelpers.ts @@ -136,7 +136,7 @@ namespace ts { // ES2018 Helpers function createAssignHelper(attributesSegments: Expression[]) { - if (context.getCompilerOptions().target! >= ScriptTarget.ES2015) { + if (getEmitScriptTarget(context.getCompilerOptions()) >= ScriptTarget.ES2015) { return factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "assign"), /*typeArguments*/ undefined, attributesSegments); diff --git a/src/compiler/factory/nodeFactory.ts b/src/compiler/factory/nodeFactory.ts index 2c2fde823ac16..a88411baad91c 100644 --- a/src/compiler/factory/nodeFactory.ts +++ b/src/compiler/factory/nodeFactory.ts @@ -5112,6 +5112,7 @@ namespace ts { node.transformFlags = propagateChildrenFlags(node.statements) | propagateChildFlags(node.endOfFileToken); + node.impliedNodeFormat = source.impliedNodeFormat; return node; } diff --git a/src/compiler/factory/utilities.ts b/src/compiler/factory/utilities.ts index 6d40ae277bd4e..8b8aa481c9877 100644 --- a/src/compiler/factory/utilities.ts +++ b/src/compiler/factory/utilities.ts @@ -466,7 +466,7 @@ namespace ts { if (compilerOptions.importHelpers && isEffectiveExternalModule(sourceFile, compilerOptions)) { let namedBindings: NamedImportBindings | undefined; const moduleKind = getEmitModuleKind(compilerOptions); - if (moduleKind >= ModuleKind.ES2015 && moduleKind <= ModuleKind.ESNext) { + if ((moduleKind >= ModuleKind.ES2015 && moduleKind <= ModuleKind.ESNext) || sourceFile.impliedNodeFormat === ModuleKind.ESNext) { // use named imports const helpers = getEmitHelpers(sourceFile); if (helpers) { @@ -523,9 +523,9 @@ namespace ts { } const moduleKind = getEmitModuleKind(compilerOptions); - let create = (hasExportStarsToExportValues || (compilerOptions.esModuleInterop && hasImportStarOrImportDefault)) + let create = (hasExportStarsToExportValues || (getESModuleInterop(compilerOptions) && hasImportStarOrImportDefault)) && moduleKind !== ModuleKind.System - && moduleKind < ModuleKind.ES2015; + && (moduleKind < ModuleKind.ES2015 || node.impliedNodeFormat === ModuleKind.CommonJS); if (!create) { const helpers = getEmitHelpers(node); if (helpers) { diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index 897aafa261113..ab5f754e9eeb3 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -113,6 +113,7 @@ namespace ts { typesVersions?: MapLike>; main?: string; tsconfig?: string; + type?: string; } interface PackageJson extends PackageJsonPathFields { @@ -816,7 +817,20 @@ namespace ts { else { let moduleResolution = compilerOptions.moduleResolution; if (moduleResolution === undefined) { - moduleResolution = getEmitModuleKind(compilerOptions) === ModuleKind.CommonJS ? ModuleResolutionKind.NodeJs : ModuleResolutionKind.Classic; + switch (getEmitModuleKind(compilerOptions)) { + case ModuleKind.CommonJS: + moduleResolution = ModuleResolutionKind.NodeJs; + break; + case ModuleKind.Node12: + moduleResolution = ModuleResolutionKind.Node12; + break; + case ModuleKind.NodeNext: + moduleResolution = ModuleResolutionKind.NodeNext; + break; + default: + moduleResolution = ModuleResolutionKind.Classic; + break; + } if (traceEnabled) { trace(host, Diagnostics.Module_resolution_kind_is_not_specified_using_0, ModuleResolutionKind[moduleResolution]); } @@ -829,6 +843,8 @@ namespace ts { perfLogger.logStartResolveModule(moduleName /* , containingFile, ModuleResolutionKind[moduleResolution]*/); switch (moduleResolution) { + case ModuleResolutionKind.Node12: + case ModuleResolutionKind.NodeNext: // TODO: Implement node12/nodenext resolution rules case ModuleResolutionKind.NodeJs: result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference); break; @@ -1310,7 +1326,8 @@ namespace ts { versionPaths: VersionPaths | undefined; } - function getPackageJsonInfo(packageDirectory: string, onlyRecordFailures: boolean, state: ModuleResolutionState): PackageJsonInfo | undefined { + /*@internal*/ + export function getPackageJsonInfo(packageDirectory: string, onlyRecordFailures: boolean, state: ModuleResolutionState): PackageJsonInfo | undefined { const { host, traceEnabled } = state; const packageJsonPath = combinePaths(packageDirectory, "package.json"); if (onlyRecordFailures) { diff --git a/src/compiler/moduleSpecifiers.ts b/src/compiler/moduleSpecifiers.ts index f246f44c013d4..de42460d54aeb 100644 --- a/src/compiler/moduleSpecifiers.ts +++ b/src/compiler/moduleSpecifiers.ts @@ -763,6 +763,14 @@ namespace ts.moduleSpecifiers { case Extension.Jsx: case Extension.Json: return ext; + case Extension.Dmts: + case Extension.Mts: + case Extension.Mjs: + return Extension.Mjs; + case Extension.Dcts: + case Extension.Cts: + case Extension.Cjs: + return Extension.Cjs; default: return undefined; } diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 9775890c53075..d52b9bec5da7a 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -738,6 +738,55 @@ namespace ts { configFileParseResult.errors; } + /** + * A function for determining if a given file is esm or cjs format, assuming modern node module resolution rules, as configured by the + * `options` parameter. + * + * @param fileName The normalized absolute path to check the format of (it need not exist on disk) + * @param packageJsonInfoCache (Optional) A cache for package file lookups - it's best to have a cache when this function is called often + * @param host The ModuleResolutionHost which can perform the filesystem lookups for package json data + * @param options The compiler options to perform the analysis under - relevant options are `moduleResolution` and `traceResolution` + * @returns `undefined` if the path has no relevant implied format, `ModuleKind.ESNext` for esm format, and `ModuleKind.CommonJS` for cjs format + */ + export function getImpliedNodeFormatForFile(fileName: Path, packageJsonInfoCache: PackageJsonInfoCache | undefined, host: ModuleResolutionHost, options: CompilerOptions): ModuleKind.ESNext | ModuleKind.CommonJS | undefined { + switch (getEmitModuleResolutionKind(options)) { + case ModuleResolutionKind.Node12: + case ModuleResolutionKind.NodeNext: + return fileExtensionIsOneOf(fileName, [Extension.Dmts, Extension.Mts, Extension.Mjs]) ? ModuleKind.ESNext : + fileExtensionIsOneOf(fileName, [Extension.Dcts, Extension.Cts, Extension.Cjs]) ? ModuleKind.CommonJS : + fileExtensionIsOneOf(fileName, [Extension.Dts, Extension.Ts, Extension.Tsx, Extension.Js, Extension.Jsx]) ? lookupFromPackageJson() : + undefined; // other extensions, like `json` or `tsbuildinfo`, are set as `undefined` here but they should never be fed through the transformer pipeline + default: + return undefined; + } + function lookupFromPackageJson(): ModuleKind.ESNext | ModuleKind.CommonJS { + const state: { + host: ModuleResolutionHost; + compilerOptions: CompilerOptions; + traceEnabled: boolean; + failedLookupLocations: Push; + resultFromCache?: ResolvedModuleWithFailedLookupLocations; + packageJsonInfoCache: PackageJsonInfoCache | undefined; + } = { + host, + compilerOptions: options, + traceEnabled: isTraceEnabled(options, host), + failedLookupLocations: [], + packageJsonInfoCache + }; + const parts = getPathComponents(fileName); + parts.pop(); + while (parts.length > 0) { + const pkg = getPackageJsonInfo(getPathFromPathComponents(parts), /*onlyRecordFailures*/ false, state); + if (pkg) { + return pkg.packageJsonContent?.type === "module" ? ModuleKind.ESNext : ModuleKind.CommonJS; + } + parts.pop(); + } + return ModuleKind.CommonJS; + } + } + /** * Determine if source file needs to be re-created even if its text hasn't changed */ @@ -1453,8 +1502,8 @@ namespace ts { for (const oldSourceFile of oldSourceFiles) { let newSourceFile = host.getSourceFileByPath - ? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, options.target!, /*onError*/ undefined, shouldCreateNewSourceFile) - : host.getSourceFile(oldSourceFile.fileName, options.target!, /*onError*/ undefined, shouldCreateNewSourceFile); // TODO: GH#18217 + ? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, getEmitScriptTarget(options), /*onError*/ undefined, shouldCreateNewSourceFile) + : host.getSourceFile(oldSourceFile.fileName, getEmitScriptTarget(options), /*onError*/ undefined, shouldCreateNewSourceFile); // TODO: GH#18217 if (!newSourceFile) { return StructureIsReused.Not; @@ -2609,7 +2658,7 @@ namespace ts { // We haven't looked for this file, do so now and cache result const file = host.getSourceFile( fileName, - options.target!, + getEmitScriptTarget(options), hostErrorMessage => addFilePreprocessingFileExplainingDiagnostic(/*file*/ undefined, reason, Diagnostics.Cannot_read_file_0_Colon_1, [fileName, hostErrorMessage]), shouldCreateNewSourceFile ); @@ -2642,6 +2691,10 @@ namespace ts { file.path = path; file.resolvedPath = toPath(fileName); file.originalFileName = originalFileName; + // It's a _little odd_ that we can't set `impliedNodeFormat` until the program step - but it's the first and only time we have a resolution cache + // and a freshly made source file node on hand at the same time, and we need both to set the field. Persisting the resolution cache all the way + // to the check and emit steps would be bad - so we much prefer detecting and storing the format information on the source file node upfront. + file.impliedNodeFormat = getImpliedNodeFormatForFile(file.resolvedPath, moduleResolutionCache?.getPackageJsonInfoCache(), host, options); addFileIncludeReason(file, reason); if (host.useCaseSensitiveFileNames()) { @@ -3176,7 +3229,7 @@ namespace ts { createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_with_option_1, "noImplicitUseStrict", "alwaysStrict"); } - const languageVersion = options.target || ScriptTarget.ES3; + const languageVersion = getEmitScriptTarget(options); const firstNonAmbientExternalModuleSourceFile = find(files, f => isExternalModule(f) && !f.isDeclarationFile); if (options.isolatedModules) { @@ -3461,7 +3514,7 @@ namespace ts { message = Diagnostics.File_is_library_specified_here; break; } - const target = forEachEntry(targetOptionDeclaration.type, (value, key) => value === options.target ? key : undefined); + const target = forEachEntry(targetOptionDeclaration.type, (value, key) => value === getEmitScriptTarget(options) ? key : undefined); configFileNode = target ? getOptionsSyntaxByValue("target", target) : undefined; message = Diagnostics.File_is_default_library_for_target_specified_here; break; diff --git a/src/compiler/transformer.ts b/src/compiler/transformer.ts index 732205c00a34b..4c4b07d23a43a 100644 --- a/src/compiler/transformer.ts +++ b/src/compiler/transformer.ts @@ -8,6 +8,9 @@ namespace ts { return transformECMAScriptModule; case ModuleKind.System: return transformSystemModule; + case ModuleKind.Node12: + case ModuleKind.NodeNext: + return transformNodeModule; default: return transformModule; } diff --git a/src/compiler/transformers/classFields.ts b/src/compiler/transformers/classFields.ts index 935c549dbcea5..de979f8a0ffa9 100644 --- a/src/compiler/transformers/classFields.ts +++ b/src/compiler/transformers/classFields.ts @@ -172,7 +172,7 @@ namespace ts { function transformSourceFile(node: SourceFile) { const options = context.getCompilerOptions(); if (node.isDeclarationFile - || useDefineForClassFields && options.target === ScriptTarget.ESNext) { + || useDefineForClassFields && getEmitScriptTarget(options) === ScriptTarget.ESNext) { return node; } const visited = visitEachChild(node, visitor, context); diff --git a/src/compiler/transformers/jsx.ts b/src/compiler/transformers/jsx.ts index 55c606f883218..7cc7c53550330 100644 --- a/src/compiler/transformers/jsx.ts +++ b/src/compiler/transformers/jsx.ts @@ -292,7 +292,7 @@ namespace ts { // When there are no attributes, React wants "null" } else { - const target = compilerOptions.target; + const target = getEmitScriptTarget(compilerOptions); if (target && target >= ScriptTarget.ES2018) { objectProperties = factory.createObjectLiteralExpression( flatten( diff --git a/src/compiler/transformers/module/esnextAnd2015.ts b/src/compiler/transformers/module/esnextAnd2015.ts index 4a7e297722e86..a4e75b84c8b7f 100644 --- a/src/compiler/transformers/module/esnextAnd2015.ts +++ b/src/compiler/transformers/module/esnextAnd2015.ts @@ -5,7 +5,10 @@ namespace ts { factory, getEmitHelperFactory: emitHelpers, } = context; + const host = context.getEmitHost(); + const resolver = context.getEmitResolver(); const compilerOptions = context.getCompilerOptions(); + const languageVersion = getEmitScriptTarget(compilerOptions); const previousOnEmitNode = context.onEmitNode; const previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; @@ -14,6 +17,8 @@ namespace ts { context.enableSubstitution(SyntaxKind.Identifier); let helperNameSubstitutions: ESMap | undefined; + let currentSourceFile: SourceFile | undefined; + let importRequireStatements: [ImportDeclaration, VariableStatement] | undefined; return chainBundle(context, transformSourceFile); function transformSourceFile(node: SourceFile) { @@ -22,7 +27,16 @@ namespace ts { } if (isExternalModule(node) || compilerOptions.isolatedModules) { - const result = updateExternalModule(node); + currentSourceFile = node; + importRequireStatements = undefined; + let result = updateExternalModule(node); + currentSourceFile = undefined; + if (importRequireStatements) { + result = factory.updateSourceFile( + result, + setTextRange(factory.createNodeArray(insertStatementsAfterCustomPrologue(result.statements.slice(), importRequireStatements)), result.statements), + ); + } if (!isExternalModule(node) || some(result.statements, isExternalModuleIndicator)) { return result; } @@ -55,8 +69,10 @@ namespace ts { function visitor(node: Node): VisitResult { switch (node.kind) { case SyntaxKind.ImportEqualsDeclaration: - // Elide `import=` as it is not legal with --module ES6 - return undefined; + // Though an error in es2020 modules, in node-flavor es2020 modules, we can helpfully transform this to a synthetic `require` call + // To give easy access to a synchronous `require` in node-flavor esm. We do the transform even in scenarios where we error, but `import.meta.url` + // is available, just because the output is reasonable for a node-like runtime. + return getEmitScriptTarget(compilerOptions) >= ModuleKind.ES2020 ? visitImportEqualsDeclaration(node as ImportEqualsDeclaration) : undefined; case SyntaxKind.ExportAssignment: return visitExportAssignment(node as ExportAssignment); case SyntaxKind.ExportDeclaration: @@ -67,6 +83,106 @@ namespace ts { return node; } + /** + * Creates a `require()` call to import an external module. + * + * @param importNode The declararation to import. + */ + function createRequireCall(importNode: ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration) { + const moduleName = getExternalModuleNameLiteral(factory, importNode, Debug.checkDefined(currentSourceFile), host, resolver, compilerOptions); + const args: Expression[] = []; + if (moduleName) { + args.push(moduleName); + } + + if (!importRequireStatements) { + const createRequireName = factory.createUniqueName("_createRequire", GeneratedIdentifierFlags.Optimistic | GeneratedIdentifierFlags.FileLevel); + const importStatement = factory.createImportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, + factory.createImportClause( + /*isTypeOnly*/ false, + /*name*/ undefined, + factory.createNamedImports([ + factory.createImportSpecifier(factory.createIdentifier("createRequire"), createRequireName) + ]) + ), + factory.createStringLiteral("module") + ); + const requireHelperName = factory.createUniqueName("__require", GeneratedIdentifierFlags.Optimistic | GeneratedIdentifierFlags.FileLevel); + const requireStatement = factory.createVariableStatement( + /*modifiers*/ undefined, + factory.createVariableDeclarationList( + [ + factory.createVariableDeclaration( + requireHelperName, + /*exclamationToken*/ undefined, + /*type*/ undefined, + factory.createCallExpression(factory.cloneNode(createRequireName), /*typeArguments*/ undefined, [ + factory.createPropertyAccessExpression(factory.createMetaProperty(SyntaxKind.ImportKeyword, factory.createIdentifier("meta")), factory.createIdentifier("url")) + ]) + ) + ], + /*flags*/ languageVersion >= ScriptTarget.ES2015 ? NodeFlags.Const : NodeFlags.None + ) + ); + importRequireStatements = [importStatement, requireStatement]; + + } + + const name = importRequireStatements[1].declarationList.declarations[0].name; + Debug.assertNode(name, isIdentifier); + return factory.createCallExpression(factory.cloneNode(name), /*typeArguments*/ undefined, args); + } + + /** + * Visits an ImportEqualsDeclaration node. + * + * @param node The node to visit. + */ + function visitImportEqualsDeclaration(node: ImportEqualsDeclaration): VisitResult { + Debug.assert(isExternalModuleImportEqualsDeclaration(node), "import= for internal module references should be handled in an earlier transformer."); + + let statements: Statement[] | undefined; + statements = append(statements, + setOriginalNode( + setTextRange( + factory.createVariableStatement( + /*modifiers*/ undefined, + factory.createVariableDeclarationList( + [ + factory.createVariableDeclaration( + factory.cloneNode(node.name), + /*exclamationToken*/ undefined, + /*type*/ undefined, + createRequireCall(node) + ) + ], + /*flags*/ languageVersion >= ScriptTarget.ES2015 ? NodeFlags.Const : NodeFlags.None + ) + ), + node), + node + ) + ); + + statements = appendExportsOfImportEqualsDeclaration(statements, node); + + return singleOrMany(statements); + } + + function appendExportsOfImportEqualsDeclaration(statements: Statement[] | undefined, node: ImportEqualsDeclaration) { + if (hasSyntacticModifier(node, ModifierFlags.Export)) { + statements = append(statements, factory.createExportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, + node.isTypeOnly, + factory.createNamedExports([factory.createExportSpecifier(/*propertyName*/ undefined, idText(node.name))]) + )); + } + return statements; + } + function visitExportAssignment(node: ExportAssignment): VisitResult { // Elide `export=` as it is not legal with --module ES6 return node.isExportEquals ? undefined : node; diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index 2a7440bd893b8..dd06ca804f0f0 100644 --- a/src/compiler/transformers/module/module.ts +++ b/src/compiler/transformers/module/module.ts @@ -548,7 +548,7 @@ namespace ts { return node; } - if (isImportCall(node)) { + if (isImportCall(node) && currentSourceFile.impliedNodeFormat === undefined) { return visitImportCallExpression(node); } else if (isDestructuringAssignment(node)) { @@ -717,7 +717,7 @@ namespace ts { } const promise = factory.createNewExpression(factory.createIdentifier("Promise"), /*typeArguments*/ undefined, [func]); - if (compilerOptions.esModuleInterop) { + if (getESModuleInterop(compilerOptions)) { return factory.createCallExpression(factory.createPropertyAccessExpression(promise, factory.createIdentifier("then")), /*typeArguments*/ undefined, [emitHelpers().createImportStarCallbackHelper()]); } return promise; @@ -731,7 +731,7 @@ namespace ts { // if we simply do require in resolve callback in Promise constructor. We will execute the loading immediately const promiseResolveCall = factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Promise"), "resolve"), /*typeArguments*/ undefined, /*argumentsArray*/ []); let requireCall: Expression = factory.createCallExpression(factory.createIdentifier("require"), /*typeArguments*/ undefined, arg ? [arg] : []); - if (compilerOptions.esModuleInterop) { + if (getESModuleInterop(compilerOptions)) { requireCall = emitHelpers().createImportStarHelper(requireCall); } @@ -767,7 +767,7 @@ namespace ts { } function getHelperExpressionForExport(node: ExportDeclaration, innerExpr: Expression) { - if (!compilerOptions.esModuleInterop || getEmitFlags(node) & EmitFlags.NeverApplyImportHelper) { + if (!getESModuleInterop(compilerOptions) || getEmitFlags(node) & EmitFlags.NeverApplyImportHelper) { return innerExpr; } if (getExportNeedsImportStarHelper(node)) { @@ -777,7 +777,7 @@ namespace ts { } function getHelperExpressionForImport(node: ImportDeclaration, innerExpr: Expression) { - if (!compilerOptions.esModuleInterop || getEmitFlags(node) & EmitFlags.NeverApplyImportHelper) { + if (!getESModuleInterop(compilerOptions) || getEmitFlags(node) & EmitFlags.NeverApplyImportHelper) { return innerExpr; } if (getImportNeedsImportStarHelper(node)) { @@ -1037,7 +1037,7 @@ namespace ts { } else { const exportNeedsImportDefault = - !!compilerOptions.esModuleInterop && + !!getESModuleInterop(compilerOptions) && !(getEmitFlags(node) & EmitFlags.NeverApplyImportHelper) && idText(specifier.propertyName || specifier.name) === "default"; const exportedValue = factory.createPropertyAccessExpression( diff --git a/src/compiler/transformers/module/node.ts b/src/compiler/transformers/module/node.ts new file mode 100644 index 0000000000000..b1addf4f3ece2 --- /dev/null +++ b/src/compiler/transformers/module/node.ts @@ -0,0 +1,84 @@ +/*@internal*/ +namespace ts { + export function transformNodeModule(context: TransformationContext) { + const previousOnSubstituteNode = context.onSubstituteNode; + const previousOnEmitNode = context.onEmitNode; + + const esmTransform = transformECMAScriptModule(context); + + const esmOnSubstituteNode = context.onSubstituteNode; + const esmOnEmitNode = context.onEmitNode; + + context.onSubstituteNode = previousOnSubstituteNode; + context.onEmitNode = previousOnEmitNode; + + const cjsTransform = transformModule(context); + + const cjsOnSubstituteNode = context.onSubstituteNode; + const cjsOnEmitNode = context.onEmitNode; + + context.onSubstituteNode = onSubstituteNode; + context.onEmitNode = onEmitNode; + context.enableSubstitution(SyntaxKind.SourceFile); + context.enableEmitNotification(SyntaxKind.SourceFile); + + let currentSourceFile: SourceFile | undefined; + return transformSourceFileOrBundle; + + function onSubstituteNode(hint: EmitHint, node: Node) { + if (isSourceFile(node)) { + currentSourceFile = node; + // Neither component transform wants substitution notifications for `SourceFile`s, and, in fact, relies on + // the source file emit notification to setup scope variables for substitutions (so we _cannot_ call their substitute + // functions on source files safely, as that context only gets setup in a later pipeline phase!) + return previousOnSubstituteNode(hint, node); + } + else { + if (!currentSourceFile) { + return previousOnSubstituteNode(hint, node); + } + if (currentSourceFile.impliedNodeFormat === ModuleKind.ESNext) { + return esmOnSubstituteNode(hint, node); + } + return cjsOnSubstituteNode(hint, node); + } + } + + function onEmitNode(hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void): void { + if (isSourceFile(node)) { + currentSourceFile = node; + } + if (!currentSourceFile) { + return previousOnEmitNode(hint, node, emitCallback); + } + if (currentSourceFile.impliedNodeFormat === ModuleKind.ESNext) { + return esmOnEmitNode(hint, node, emitCallback); + } + return cjsOnEmitNode(hint, node, emitCallback); + } + + function getModuleTransformForFile(file: SourceFile): (typeof esmTransform) { + return file.impliedNodeFormat === ModuleKind.ESNext ? esmTransform : cjsTransform; + } + + function transformSourceFile(node: SourceFile) { + if (node.isDeclarationFile) { + return node; + } + + currentSourceFile = node; + const result = getModuleTransformForFile(node)(node); + currentSourceFile = undefined; + Debug.assert(isSourceFile(result)); + return result; + } + + function transformSourceFileOrBundle(node: SourceFile | Bundle) { + return node.kind === SyntaxKind.SourceFile ? transformSourceFile(node) : transformBundle(node); + } + + function transformBundle(node: Bundle) { + return context.factory.createBundle(map(node.sourceFiles, transformSourceFile), node.prepends); + } + } +} diff --git a/src/compiler/tsconfig.json b/src/compiler/tsconfig.json index 5f118cf1e47bd..c5db068d120c1 100644 --- a/src/compiler/tsconfig.json +++ b/src/compiler/tsconfig.json @@ -63,6 +63,7 @@ "transformers/module/module.ts", "transformers/module/system.ts", "transformers/module/esnextAnd2015.ts", + "transformers/module/node.ts", "transformers/declarations/diagnostics.ts", "transformers/declarations.ts", "transformer.ts", diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 4d568677b2e20..e101c6614e183 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3547,6 +3547,20 @@ namespace ts { hasNoDefaultLib: boolean; languageVersion: ScriptTarget; + + /** + * When `module` is `Node12` or `NodeNext`, this field controls weather the + * source file in question is an ESNext-output-format file, or a CommonJS-output-format + * module. This is derived by the module resolver as it looks up the file, since + * it is derived from either the file extension of the module, or the containing + * `package.json` context, and affects both checking and emit. + * + * It is _public_ so that (pre)transformers can set this field, + * since it switches the builtin `node` module transform. Generally speaking, if unset, + * the field is treated as though it is `ModuleKind.CommonJS`. + */ + impliedNodeFormat?: ModuleKind.ESNext | ModuleKind.CommonJS; + /* @internal */ scriptKind: ScriptKind; /** @@ -5914,7 +5928,13 @@ namespace ts { export enum ModuleResolutionKind { Classic = 1, - NodeJs = 2 + NodeJs = 2, + // Starting with node12, node's module resolver has significant departures from tranditional cjs resolution + // to better support ecmascript modules and their use within node - more features are still being added, so + // we can expect it co change over time, and as such, offer both a `NodeNext` moving resolution target, and a `Node12` + // version-anchored resolution target + Node12 = 3, + NodeNext = 99, // Not simply `Node12` so that compiled code linked against TS can use the `Next` value reliably (same as with `ModuleKind`) } export interface PluginImport { @@ -6067,7 +6087,7 @@ namespace ts { suppressExcessPropertyErrors?: boolean; suppressImplicitAnyIndexErrors?: boolean; /* @internal */ suppressOutputPathCheck?: boolean; - target?: ScriptTarget; // TODO: GH#18217 frequently asserted as defined + target?: ScriptTarget; traceResolution?: boolean; useUnknownInCatchVariables?: boolean; resolveJsonModule?: boolean; @@ -6119,7 +6139,11 @@ namespace ts { // module kind). ES2015 = 5, ES2020 = 6, - ESNext = 99 + ESNext = 99, + + // Node12+ is an amalgam of commonjs (albeit updated) and es2020+, and represents a distinct module system from es2020/esnext + Node12 = 100, + NodeNext = 199, } export const enum JsxEmit { @@ -6514,7 +6538,13 @@ namespace ts { Js = ".js", Jsx = ".jsx", Json = ".json", - TsBuildInfo = ".tsbuildinfo" + TsBuildInfo = ".tsbuildinfo", + Mjs = ".mjs", + Mts = ".mts", + Dmts = ".d.mts", + Cjs = ".cjs", + Cts = ".cts", + Dcts = ".d.cts", } export interface ResolvedModuleWithFailedLookupLocations { diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index ab8bc3edfcb4b..df03bfa8d743d 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -791,8 +791,12 @@ namespace ts { return symbol.declarations?.find(d => !isExternalModuleAugmentation(d) && !(isModuleDeclaration(d) && isGlobalScopeAugmentation(d))); } + function isCommonJSContainingModuleKind(kind: ModuleKind) { + return kind === ModuleKind.CommonJS || kind === ModuleKind.Node12 || kind === ModuleKind.NodeNext; + } + export function isEffectiveExternalModule(node: SourceFile, compilerOptions: CompilerOptions) { - return isExternalModule(node) || compilerOptions.isolatedModules || ((getEmitModuleKind(compilerOptions) === ModuleKind.CommonJS) && !!node.commonJsModuleIndicator); + return isExternalModule(node) || compilerOptions.isolatedModules || (isCommonJSContainingModuleKind(getEmitModuleKind(compilerOptions)) && !!node.commonJsModuleIndicator); } /** @@ -6070,8 +6074,11 @@ namespace ts { return scriptKind === ScriptKind.TSX || scriptKind === ScriptKind.JSX || scriptKind === ScriptKind.JS || scriptKind === ScriptKind.JSON ? LanguageVariant.JSX : LanguageVariant.Standard; } - export function getEmitScriptTarget(compilerOptions: CompilerOptions) { - return compilerOptions.target || ScriptTarget.ES3; + export function getEmitScriptTarget(compilerOptions: {module?: CompilerOptions["module"], target?: CompilerOptions["target"]}) { + return compilerOptions.target || + (compilerOptions.module === ModuleKind.Node12 && ScriptTarget.ES2020) || + (compilerOptions.module === ModuleKind.NodeNext && ScriptTarget.ESNext) || + ScriptTarget.ES3; } export function getEmitModuleKind(compilerOptions: {module?: CompilerOptions["module"], target?: CompilerOptions["target"]}) { @@ -6083,7 +6090,20 @@ namespace ts { export function getEmitModuleResolutionKind(compilerOptions: CompilerOptions) { let moduleResolution = compilerOptions.moduleResolution; if (moduleResolution === undefined) { - moduleResolution = getEmitModuleKind(compilerOptions) === ModuleKind.CommonJS ? ModuleResolutionKind.NodeJs : ModuleResolutionKind.Classic; + switch (getEmitModuleKind(compilerOptions)) { + case ModuleKind.CommonJS: + moduleResolution = ModuleResolutionKind.NodeJs; + break; + case ModuleKind.Node12: + moduleResolution = ModuleResolutionKind.Node12; + break; + case ModuleKind.NodeNext: + moduleResolution = ModuleResolutionKind.NodeNext; + break; + default: + moduleResolution = ModuleResolutionKind.Classic; + break; + } } return moduleResolution; } @@ -6113,11 +6133,23 @@ namespace ts { return !!(getEmitDeclarations(options) && options.declarationMap); } + export function getESModuleInterop(compilerOptions: CompilerOptions) { + if (compilerOptions.esModuleInterop !== undefined) { + return compilerOptions.esModuleInterop; + } + switch (getEmitModuleKind(compilerOptions)) { + case ModuleKind.Node12: + case ModuleKind.NodeNext: + return true; + } + return undefined; + } + export function getAllowSyntheticDefaultImports(compilerOptions: CompilerOptions) { const moduleKind = getEmitModuleKind(compilerOptions); return compilerOptions.allowSyntheticDefaultImports !== undefined ? compilerOptions.allowSyntheticDefaultImports - : compilerOptions.esModuleInterop || + : getESModuleInterop(compilerOptions) || moduleKind === ModuleKind.System; } @@ -6153,7 +6185,7 @@ namespace ts { } export function getUseDefineForClassFields(compilerOptions: CompilerOptions): boolean { - return compilerOptions.useDefineForClassFields === undefined ? compilerOptions.target === ScriptTarget.ESNext : compilerOptions.useDefineForClassFields; + return compilerOptions.useDefineForClassFields === undefined ? getEmitScriptTarget(compilerOptions) === ScriptTarget.ESNext : compilerOptions.useDefineForClassFields; } export function compilerOptionsAffectSemanticDiagnostics(newOptions: CompilerOptions, oldOptions: CompilerOptions): boolean { diff --git a/src/compiler/utilitiesPublic.ts b/src/compiler/utilitiesPublic.ts index b9236521cba67..ae228d11a6727 100644 --- a/src/compiler/utilitiesPublic.ts +++ b/src/compiler/utilitiesPublic.ts @@ -11,7 +11,7 @@ namespace ts { } export function getDefaultLibFileName(options: CompilerOptions): string { - switch (options.target) { + switch (getEmitScriptTarget(options)) { case ScriptTarget.ESNext: return "lib.esnext.full.d.ts"; case ScriptTarget.ES2021: diff --git a/src/compiler/watch.ts b/src/compiler/watch.ts index 78dc141344741..d444e63c800c9 100644 --- a/src/compiler/watch.ts +++ b/src/compiler/watch.ts @@ -279,7 +279,7 @@ namespace ts { ); case FileIncludeKind.LibFile: if (reason.index !== undefined) return chainDiagnosticMessages(/*details*/ undefined, Diagnostics.Library_0_specified_in_compilerOptions, options.lib![reason.index]); - const target = forEachEntry(targetOptionDeclaration.type, (value, key) => value === options.target ? key : undefined); + const target = forEachEntry(targetOptionDeclaration.type, (value, key) => value === getEmitScriptTarget(options) ? key : undefined); return chainDiagnosticMessages( /*details*/ undefined, target ? diff --git a/src/harness/compilerImpl.ts b/src/harness/compilerImpl.ts index 41003356fc23a..7d42ccea2c0bd 100644 --- a/src/harness/compilerImpl.ts +++ b/src/harness/compilerImpl.ts @@ -249,7 +249,7 @@ namespace compiler { } // establish defaults (aligns with old harness) - if (compilerOptions.target === undefined) compilerOptions.target = ts.ScriptTarget.ES3; + if (compilerOptions.target === undefined && compilerOptions.module !== ts.ModuleKind.Node12 && compilerOptions.module !== ts.ModuleKind.NodeNext) compilerOptions.target = ts.ScriptTarget.ES3; if (compilerOptions.newLine === undefined) compilerOptions.newLine = ts.NewLineKind.CarriageReturnLineFeed; if (compilerOptions.skipDefaultLibCheck === undefined) compilerOptions.skipDefaultLibCheck = true; if (compilerOptions.noErrorTruncation === undefined) compilerOptions.noErrorTruncation = true; diff --git a/src/harness/harnessIO.ts b/src/harness/harnessIO.ts index a34e4a6e45f13..f7775ed98218a 100644 --- a/src/harness/harnessIO.ts +++ b/src/harness/harnessIO.ts @@ -265,7 +265,7 @@ namespace Harness { } export function getDefaultLibFileName(options: ts.CompilerOptions): string { - switch (options.target) { + switch (ts.getEmitScriptTarget(options)) { case ts.ScriptTarget.ESNext: case ts.ScriptTarget.ES2017: return "lib.es2017.d.ts"; @@ -385,7 +385,7 @@ namespace Harness { symlinks?: vfs.FileSet ): compiler.CompilationResult { const options: ts.CompilerOptions & HarnessOptions = compilerOptions ? ts.cloneCompilerOptions(compilerOptions) : { noResolve: false }; - options.target = options.target || ts.ScriptTarget.ES3; + options.target = ts.getEmitScriptTarget(options); options.newLine = options.newLine || ts.NewLineKind.CarriageReturnLineFeed; options.noErrorTruncation = true; options.skipDefaultLibCheck = typeof options.skipDefaultLibCheck === "undefined" ? true : options.skipDefaultLibCheck; @@ -891,7 +891,7 @@ namespace Harness { jsCode += "\r\n"; } if (!result.diagnostics.length && !ts.endsWith(file.file, ts.Extension.Json)) { - const fileParseResult = ts.createSourceFile(file.file, file.text, options.target || ts.ScriptTarget.ES3, /*parentNodes*/ false, ts.endsWith(file.file, "x") ? ts.ScriptKind.JSX : ts.ScriptKind.JS); + const fileParseResult = ts.createSourceFile(file.file, file.text, ts.getEmitScriptTarget(options), /*parentNodes*/ false, ts.endsWith(file.file, "x") ? ts.ScriptKind.JSX : ts.ScriptKind.JS); if (ts.length(fileParseResult.parseDiagnostics)) { jsCode += getErrorBaseline([file.asTestFile()], fileParseResult.parseDiagnostics); return; diff --git a/src/services/codefixes/convertFunctionToEs6Class.ts b/src/services/codefixes/convertFunctionToEs6Class.ts index 70de7a1978d14..8a20f68840d4c 100644 --- a/src/services/codefixes/convertFunctionToEs6Class.ts +++ b/src/services/codefixes/convertFunctionToEs6Class.ts @@ -259,7 +259,7 @@ namespace ts.codefix { } if (isStringLiteralLike(propName)) { - return isIdentifierText(propName.text, compilerOptions.target) ? factory.createIdentifier(propName.text) + return isIdentifierText(propName.text, getEmitScriptTarget(compilerOptions)) ? factory.createIdentifier(propName.text) : isNoSubstitutionTemplateLiteral(propName) ? factory.createStringLiteral(propName.text, quotePreference === QuotePreference.Single) : propName; } diff --git a/src/services/codefixes/convertToEs6Module.ts b/src/services/codefixes/convertToEs6Module.ts index e15c507a4ef65..1a5a92abb78f8 100644 --- a/src/services/codefixes/convertToEs6Module.ts +++ b/src/services/codefixes/convertToEs6Module.ts @@ -5,7 +5,7 @@ namespace ts.codefix { getCodeActions(context) { const { sourceFile, program, preferences } = context; const changes = textChanges.ChangeTracker.with(context, changes => { - const moduleExportsChangedToDefault = convertFileToEs6Module(sourceFile, program.getTypeChecker(), changes, program.getCompilerOptions().target!, getQuotePreference(sourceFile, preferences)); + const moduleExportsChangedToDefault = convertFileToEs6Module(sourceFile, program.getTypeChecker(), changes, getEmitScriptTarget(program.getCompilerOptions()), getQuotePreference(sourceFile, preferences)); if (moduleExportsChangedToDefault) { for (const importingFile of program.getSourceFiles()) { fixImportOfModuleExports(importingFile, sourceFile, changes, getQuotePreference(importingFile, preferences)); diff --git a/src/services/codefixes/fixModuleAndTargetOptions.ts b/src/services/codefixes/fixModuleAndTargetOptions.ts index 16ea0fab7fd07..45e1185cac909 100644 --- a/src/services/codefixes/fixModuleAndTargetOptions.ts +++ b/src/services/codefixes/fixModuleAndTargetOptions.ts @@ -2,8 +2,8 @@ namespace ts.codefix { registerCodeFix({ errorCodes: [ - Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_the_target_option_is_set_to_es2017_or_higher.code, - Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_the_target_option_is_set_to_es2017_or_higher.code, + Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher.code, + Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_esnext_system_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher.code, ], getCodeActions: context => { const compilerOptions = context.program.getCompilerOptions(); diff --git a/src/services/codefixes/fixSpelling.ts b/src/services/codefixes/fixSpelling.ts index 457ccc5ee672e..c7b1d66391048 100644 --- a/src/services/codefixes/fixSpelling.ts +++ b/src/services/codefixes/fixSpelling.ts @@ -22,15 +22,15 @@ namespace ts.codefix { const info = getInfo(sourceFile, context.span.start, context, errorCode); if (!info) return undefined; const { node, suggestedSymbol } = info; - const { target } = context.host.getCompilationSettings(); - const changes = textChanges.ChangeTracker.with(context, t => doChange(t, sourceFile, node, suggestedSymbol, target!)); + const target = getEmitScriptTarget(context.host.getCompilationSettings()); + const changes = textChanges.ChangeTracker.with(context, t => doChange(t, sourceFile, node, suggestedSymbol, target)); return [createCodeFixAction("spelling", changes, [Diagnostics.Change_spelling_to_0, symbolName(suggestedSymbol)], fixId, Diagnostics.Fix_all_detected_spelling_errors)]; }, fixIds: [fixId], getAllCodeActions: context => codeFixAll(context, errorCodes, (changes, diag) => { const info = getInfo(diag.file, diag.start, context, diag.code); - const { target } = context.host.getCompilationSettings(); - if (info) doChange(changes, context.sourceFile, info.node, info.suggestedSymbol, target!); + const target = getEmitScriptTarget(context.host.getCompilationSettings()); + if (info) doChange(changes, context.sourceFile, info.node, info.suggestedSymbol, target); }), }); diff --git a/src/services/codefixes/importFixes.ts b/src/services/codefixes/importFixes.ts index fce07020f68e2..eac78eb66dc68 100644 --- a/src/services/codefixes/importFixes.ts +++ b/src/services/codefixes/importFixes.ts @@ -255,7 +255,7 @@ namespace ts.codefix { } const defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions); - if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, compilerOptions.target) === symbolName) && skipAlias(defaultInfo.symbol, checker) === exportedSymbol && isImportable(program, moduleFile, isFromPackageJson)) { + if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, getEmitScriptTarget(compilerOptions)) === symbolName) && skipAlias(defaultInfo.symbol, checker) === exportedSymbol && isImportable(program, moduleFile, isFromPackageJson)) { result.push({ symbol: defaultInfo.symbol, moduleSymbol, moduleFileName: moduleFile?.fileName, exportKind: defaultInfo.exportKind, isTypeOnly: isTypeOnlySymbol(defaultInfo.symbol, checker), isFromPackageJson }); } @@ -590,6 +590,9 @@ namespace ts.codefix { case ModuleKind.None: // Fall back to the `import * as ns` style import. return ImportKind.Namespace; + case ModuleKind.Node12: + case ModuleKind.NodeNext: + return importingFile.impliedNodeFormat === ModuleKind.ESNext ? ImportKind.Namespace : ImportKind.CommonJS; default: return Debug.assertNever(moduleKind, `Unexpected moduleKind ${moduleKind}`); } @@ -655,7 +658,7 @@ namespace ts.codefix { const compilerOptions = program.getCompilerOptions(); const defaultInfo = getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions); - if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, compilerOptions.target) === symbolName) && symbolHasMeaning(defaultInfo.symbolForMeaning, currentTokenMeaning)) { + if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, getEmitScriptTarget(compilerOptions)) === symbolName) && symbolHasMeaning(defaultInfo.symbolForMeaning, currentTokenMeaning)) { addSymbol(moduleSymbol, sourceFile, defaultInfo.symbol, defaultInfo.exportKind, program, isFromPackageJson); } diff --git a/src/services/completions.ts b/src/services/completions.ts index f5f9824b0ad4e..d1c04aaa22189 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -417,7 +417,7 @@ namespace ts.Completions { location, sourceFile, typeChecker, - compilerOptions.target!, + getEmitScriptTarget(compilerOptions), log, completionKind, preferences, @@ -431,7 +431,7 @@ namespace ts.Completions { symbolToOriginInfoMap, symbolToSortTextIdMap ); - getJSCompletionEntries(sourceFile, location.pos, uniqueNames, compilerOptions.target!, entries); // TODO: GH#18217 + getJSCompletionEntries(sourceFile, location.pos, uniqueNames, getEmitScriptTarget(compilerOptions), entries); // TODO: GH#18217 } else { if (!isNewIdentifierLocation && (!symbols || symbols.length === 0) && keywordFilters === KeywordCompletionFilters.None) { @@ -445,7 +445,7 @@ namespace ts.Completions { location, sourceFile, typeChecker, - compilerOptions.target!, + getEmitScriptTarget(compilerOptions), log, completionKind, preferences, @@ -956,7 +956,7 @@ namespace ts.Completions { // completion entry. return firstDefined(symbols, (symbol, index): SymbolCompletion | undefined => { const origin = symbolToOriginInfoMap[index]; - const info = getCompletionEntryDisplayNameForSymbol(symbol, compilerOptions.target!, origin, completionKind, completionData.isJsxIdentifierExpected); + const info = getCompletionEntryDisplayNameForSymbol(symbol, getEmitScriptTarget(compilerOptions), origin, completionKind, completionData.isJsxIdentifierExpected); return info && info.name === entryId.name && getSourceFromOrigin(origin) === entryId.source ? { type: "symbol" as const, symbol, location, origin, previousToken, isJsxInitializer, isTypeOnlyLocation } : undefined; @@ -1076,7 +1076,7 @@ namespace ts.Completions { exportedSymbol, moduleSymbol, sourceFile, - getNameForExportedSymbol(symbol, compilerOptions.target), + getNameForExportedSymbol(symbol, getEmitScriptTarget(compilerOptions)), host, program, formatContext, diff --git a/src/services/documentRegistry.ts b/src/services/documentRegistry.ts index 77e64bf618bd2..719f219025929 100644 --- a/src/services/documentRegistry.ts +++ b/src/services/documentRegistry.ts @@ -201,7 +201,7 @@ namespace ts { acquiring: boolean, scriptKind?: ScriptKind): SourceFile { scriptKind = ensureScriptKind(fileName, scriptKind); - const scriptTarget = scriptKind === ScriptKind.JSON ? ScriptTarget.JSON : compilationSettings.target || ScriptTarget.ES5; + const scriptTarget = scriptKind === ScriptKind.JSON ? ScriptTarget.JSON : getEmitScriptTarget(compilationSettings); const bucket = getOrUpdate(buckets, key, () => new Map()); const bucketEntry = bucket.get(path); let entry = bucketEntry && getDocumentRegistryEntry(bucketEntry, scriptKind); diff --git a/src/services/stringCompletions.ts b/src/services/stringCompletions.ts index ac0c1baeb6907..9255898ca7289 100644 --- a/src/services/stringCompletions.ts +++ b/src/services/stringCompletions.ts @@ -91,6 +91,12 @@ namespace ts.Completions.StringCompletions { case Extension.Jsx: return ScriptElementKindModifier.jsxModifier; case Extension.Ts: return ScriptElementKindModifier.tsModifier; case Extension.Tsx: return ScriptElementKindModifier.tsxModifier; + case Extension.Dmts: return ScriptElementKindModifier.dmtsModifier; + case Extension.Mjs: return ScriptElementKindModifier.mjsModifier; + case Extension.Mts: return ScriptElementKindModifier.mtsModifier; + case Extension.Dcts: return ScriptElementKindModifier.dctsModifier; + case Extension.Cjs: return ScriptElementKindModifier.cjsModifier; + case Extension.Cts: return ScriptElementKindModifier.ctsModifier; case Extension.TsBuildInfo: return Debug.fail(`Extension ${Extension.TsBuildInfo} is unsupported.`); case undefined: return ScriptElementKindModifier.none; default: diff --git a/src/services/transpile.ts b/src/services/transpile.ts index 0ac54f8d172ca..5b73b91bd7f47 100644 --- a/src/services/transpile.ts +++ b/src/services/transpile.ts @@ -48,7 +48,7 @@ namespace ts { // if jsx is specified then treat file as .tsx const inputFileName = transpileOptions.fileName || (transpileOptions.compilerOptions && transpileOptions.compilerOptions.jsx ? "module.tsx" : "module.ts"); - const sourceFile = createSourceFile(inputFileName, input, options.target!); // TODO: GH#18217 + const sourceFile = createSourceFile(inputFileName, input, getEmitScriptTarget(options)); if (transpileOptions.moduleName) { sourceFile.moduleName = transpileOptions.moduleName; } diff --git a/src/services/types.ts b/src/services/types.ts index 4ad9ddfa88946..ff323e392fa1b 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -1481,6 +1481,12 @@ namespace ts { jsModifier = ".js", jsxModifier = ".jsx", jsonModifier = ".json", + dmtsModifier = ".d.mts", + mtsModifier = ".mts", + mjsModifier = ".mjs", + dctsModifier = ".d.cts", + ctsModifier = ".cts", + cjsModifier = ".cjs", } export const enum ClassificationTypeNames { diff --git a/src/services/utilities.ts b/src/services/utilities.ts index cba0669f43d9f..d5edeb1246861 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -1842,7 +1842,7 @@ namespace ts { return program.getSourceFiles().some(s => !s.isDeclarationFile && !program.isSourceFileFromExternalLibrary(s) && !!s.externalModuleIndicator); } export function compilerOptionsIndicateEs6Modules(compilerOptions: CompilerOptions): boolean { - return !!compilerOptions.module || compilerOptions.target! >= ScriptTarget.ES2015 || !!compilerOptions.noEmit; + return !!compilerOptions.module || getEmitScriptTarget(compilerOptions) >= ScriptTarget.ES2015 || !!compilerOptions.noEmit; } export function createModuleSpecifierResolutionHost(program: Program, host: LanguageServiceHost): ModuleSpecifierResolutionHost { diff --git a/src/testRunner/unittests/config/commandLineParsing.ts b/src/testRunner/unittests/config/commandLineParsing.ts index 2b973991f8c41..50bb22cdfbc8e 100644 --- a/src/testRunner/unittests/config/commandLineParsing.ts +++ b/src/testRunner/unittests/config/commandLineParsing.ts @@ -159,7 +159,7 @@ namespace ts { start: undefined, length: undefined, }, { - messageText: "Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'esnext'.", + messageText: "Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'esnext', 'node12', 'nodenext'.", category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category, code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code, diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 8b537d952f339..51398e9b34d45 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -1989,6 +1989,18 @@ declare namespace ts { */ hasNoDefaultLib: boolean; languageVersion: ScriptTarget; + /** + * When `module` is `Node12` or `NodeNext`, this field controls weather the + * source file in question is an ESNext-output-format file, or a CommonJS-output-format + * module. This is derived by the module resolver as it looks up the file, since + * it is derived from either the file extension of the module, or the containing + * `package.json` context, and affects both checking and emit. + * + * It is _public_ so that (pre)transformers can set this field, + * since it switches the builtin `node` module transform. Generally speaking, if unset, + * the field is treated as though it is `ModuleKind.CommonJS`. + */ + impliedNodeFormat?: ModuleKind.ESNext | ModuleKind.CommonJS; } export interface Bundle extends Node { readonly kind: SyntaxKind.Bundle; @@ -2803,7 +2815,9 @@ declare namespace ts { } export enum ModuleResolutionKind { Classic = 1, - NodeJs = 2 + NodeJs = 2, + Node12 = 3, + NodeNext = 99 } export interface PluginImport { name: string; @@ -2964,7 +2978,9 @@ declare namespace ts { System = 4, ES2015 = 5, ES2020 = 6, - ESNext = 99 + ESNext = 99, + Node12 = 100, + NodeNext = 199 } export enum JsxEmit { None = 0, @@ -3109,7 +3125,13 @@ declare namespace ts { Js = ".js", Jsx = ".jsx", Json = ".json", - TsBuildInfo = ".tsbuildinfo" + TsBuildInfo = ".tsbuildinfo", + Mjs = ".mjs", + Mts = ".mts", + Dmts = ".d.mts", + Cjs = ".cjs", + Cts = ".cts", + Dcts = ".d.cts" } export interface ResolvedModuleWithFailedLookupLocations { readonly resolvedModule: ResolvedModuleFull | undefined; @@ -4756,6 +4778,14 @@ declare namespace ts { export {}; } declare namespace ts { + interface ModuleResolutionState { + host: ModuleResolutionHost; + compilerOptions: CompilerOptions; + traceEnabled: boolean; + failedLookupLocations: Push; + resultFromCache?: ResolvedModuleWithFailedLookupLocations; + packageJsonInfoCache: PackageJsonInfoCache | undefined; + } export function getEffectiveTypeRoots(options: CompilerOptions, host: GetEffectiveTypeRootsHost): string[] | undefined; /** * @param {string | undefined} containingFile - file that contains type reference directive, can be undefined if containing file is unknown. @@ -4918,6 +4948,17 @@ declare namespace ts { export function formatDiagnosticsWithColorAndContext(diagnostics: readonly Diagnostic[], host: FormatDiagnosticsHost): string; export function flattenDiagnosticMessageText(diag: string | DiagnosticMessageChain | undefined, newLine: string, indent?: number): string; export function getConfigFileParsingDiagnostics(configFileParseResult: ParsedCommandLine): readonly Diagnostic[]; + /** + * A function for determining if a given file is esm or cjs format, assuming modern node module resolution rules, as configured by the + * `options` parameter. + * + * @param fileName The normalized absolute path to check the format of (it need not exist on disk) + * @param packageJsonInfoCache (Optional) A cache for package file lookups - it's best to have a cache when this function is called often + * @param host The ModuleResolutionHost which can perform the filesystem lookups for package json data + * @param options The compiler options to perform the analysis under - relevant options are `moduleResolution` and `traceResolution` + * @returns `undefined` if the path has no relevant implied format, `ModuleKind.ESNext` for esm format, and `ModuleKind.CommonJS` for cjs format + */ + export function getImpliedNodeFormatForFile(fileName: Path, packageJsonInfoCache: PackageJsonInfoCache | undefined, host: ModuleResolutionHost, options: CompilerOptions): ModuleKind.ESNext | ModuleKind.CommonJS | undefined; /** * Create a new 'Program' instance. A Program is an immutable collection of 'SourceFile's and a 'CompilerOptions' * that represent a compilation unit. @@ -6501,7 +6542,13 @@ declare namespace ts { tsxModifier = ".tsx", jsModifier = ".js", jsxModifier = ".jsx", - jsonModifier = ".json" + jsonModifier = ".json", + dmtsModifier = ".d.mts", + mtsModifier = ".mts", + mjsModifier = ".mjs", + dctsModifier = ".d.cts", + ctsModifier = ".cts", + cjsModifier = ".cjs" } enum ClassificationTypeNames { comment = "comment", diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index e81307d6ecb72..017e6f61628db 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -1989,6 +1989,18 @@ declare namespace ts { */ hasNoDefaultLib: boolean; languageVersion: ScriptTarget; + /** + * When `module` is `Node12` or `NodeNext`, this field controls weather the + * source file in question is an ESNext-output-format file, or a CommonJS-output-format + * module. This is derived by the module resolver as it looks up the file, since + * it is derived from either the file extension of the module, or the containing + * `package.json` context, and affects both checking and emit. + * + * It is _public_ so that (pre)transformers can set this field, + * since it switches the builtin `node` module transform. Generally speaking, if unset, + * the field is treated as though it is `ModuleKind.CommonJS`. + */ + impliedNodeFormat?: ModuleKind.ESNext | ModuleKind.CommonJS; } export interface Bundle extends Node { readonly kind: SyntaxKind.Bundle; @@ -2803,7 +2815,9 @@ declare namespace ts { } export enum ModuleResolutionKind { Classic = 1, - NodeJs = 2 + NodeJs = 2, + Node12 = 3, + NodeNext = 99 } export interface PluginImport { name: string; @@ -2964,7 +2978,9 @@ declare namespace ts { System = 4, ES2015 = 5, ES2020 = 6, - ESNext = 99 + ESNext = 99, + Node12 = 100, + NodeNext = 199 } export enum JsxEmit { None = 0, @@ -3109,7 +3125,13 @@ declare namespace ts { Js = ".js", Jsx = ".jsx", Json = ".json", - TsBuildInfo = ".tsbuildinfo" + TsBuildInfo = ".tsbuildinfo", + Mjs = ".mjs", + Mts = ".mts", + Dmts = ".d.mts", + Cjs = ".cjs", + Cts = ".cts", + Dcts = ".d.cts" } export interface ResolvedModuleWithFailedLookupLocations { readonly resolvedModule: ResolvedModuleFull | undefined; @@ -4756,6 +4778,14 @@ declare namespace ts { export {}; } declare namespace ts { + interface ModuleResolutionState { + host: ModuleResolutionHost; + compilerOptions: CompilerOptions; + traceEnabled: boolean; + failedLookupLocations: Push; + resultFromCache?: ResolvedModuleWithFailedLookupLocations; + packageJsonInfoCache: PackageJsonInfoCache | undefined; + } export function getEffectiveTypeRoots(options: CompilerOptions, host: GetEffectiveTypeRootsHost): string[] | undefined; /** * @param {string | undefined} containingFile - file that contains type reference directive, can be undefined if containing file is unknown. @@ -4918,6 +4948,17 @@ declare namespace ts { export function formatDiagnosticsWithColorAndContext(diagnostics: readonly Diagnostic[], host: FormatDiagnosticsHost): string; export function flattenDiagnosticMessageText(diag: string | DiagnosticMessageChain | undefined, newLine: string, indent?: number): string; export function getConfigFileParsingDiagnostics(configFileParseResult: ParsedCommandLine): readonly Diagnostic[]; + /** + * A function for determining if a given file is esm or cjs format, assuming modern node module resolution rules, as configured by the + * `options` parameter. + * + * @param fileName The normalized absolute path to check the format of (it need not exist on disk) + * @param packageJsonInfoCache (Optional) A cache for package file lookups - it's best to have a cache when this function is called often + * @param host The ModuleResolutionHost which can perform the filesystem lookups for package json data + * @param options The compiler options to perform the analysis under - relevant options are `moduleResolution` and `traceResolution` + * @returns `undefined` if the path has no relevant implied format, `ModuleKind.ESNext` for esm format, and `ModuleKind.CommonJS` for cjs format + */ + export function getImpliedNodeFormatForFile(fileName: Path, packageJsonInfoCache: PackageJsonInfoCache | undefined, host: ModuleResolutionHost, options: CompilerOptions): ModuleKind.ESNext | ModuleKind.CommonJS | undefined; /** * Create a new 'Program' instance. A Program is an immutable collection of 'SourceFile's and a 'CompilerOptions' * that represent a compilation unit. @@ -6501,7 +6542,13 @@ declare namespace ts { tsxModifier = ".tsx", jsModifier = ".js", jsxModifier = ".jsx", - jsonModifier = ".json" + jsonModifier = ".json", + dmtsModifier = ".d.mts", + mtsModifier = ".mts", + mjsModifier = ".mjs", + dctsModifier = ".d.cts", + ctsModifier = ".cts", + cjsModifier = ".cjs" } enum ClassificationTypeNames { comment = "comment", diff --git a/tests/baselines/reference/awaitInNonAsyncFunction.errors.txt b/tests/baselines/reference/awaitInNonAsyncFunction.errors.txt index ee1aa75d3cc74..6a5b413c154c2 100644 --- a/tests/baselines/reference/awaitInNonAsyncFunction.errors.txt +++ b/tests/baselines/reference/awaitInNonAsyncFunction.errors.txt @@ -12,8 +12,8 @@ tests/cases/compiler/awaitInNonAsyncFunction.ts(30,9): error TS1103: 'for await' tests/cases/compiler/awaitInNonAsyncFunction.ts(31,5): error TS1308: 'await' expressions are only allowed within async functions and at the top levels of modules. tests/cases/compiler/awaitInNonAsyncFunction.ts(34,7): error TS1103: 'for await' loops are only allowed within async functions and at the top levels of modules. tests/cases/compiler/awaitInNonAsyncFunction.ts(35,5): error TS1308: 'await' expressions are only allowed within async functions and at the top levels of modules. -tests/cases/compiler/awaitInNonAsyncFunction.ts(39,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher. -tests/cases/compiler/awaitInNonAsyncFunction.ts(40,1): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher. +tests/cases/compiler/awaitInNonAsyncFunction.ts(39,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +tests/cases/compiler/awaitInNonAsyncFunction.ts(40,1): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. ==== tests/cases/compiler/awaitInNonAsyncFunction.ts (16 errors) ==== @@ -97,7 +97,7 @@ tests/cases/compiler/awaitInNonAsyncFunction.ts(40,1): error TS1378: Top-level ' for await (const _ of []); ~~~~~ -!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher. +!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. await null; ~~~~~ -!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher. \ No newline at end of file +!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. \ No newline at end of file diff --git a/tests/baselines/reference/emitHelpersWithLocalCollisions(module=node12).js b/tests/baselines/reference/emitHelpersWithLocalCollisions(module=node12).js new file mode 100644 index 0000000000000..8aed6c9347aa2 --- /dev/null +++ b/tests/baselines/reference/emitHelpersWithLocalCollisions(module=node12).js @@ -0,0 +1,27 @@ +//// [a.ts] +declare var dec: any, __decorate: any; +@dec export class A { +} + +const o = { a: 1 }; +const y = { ...o }; + + +//// [a.js] +"use strict"; +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.A = void 0; +let A = class A { +}; +A = __decorate([ + dec +], A); +exports.A = A; +const o = { a: 1 }; +const y = Object.assign({}, o); diff --git a/tests/baselines/reference/emitHelpersWithLocalCollisions(module=nodenext).js b/tests/baselines/reference/emitHelpersWithLocalCollisions(module=nodenext).js new file mode 100644 index 0000000000000..8aed6c9347aa2 --- /dev/null +++ b/tests/baselines/reference/emitHelpersWithLocalCollisions(module=nodenext).js @@ -0,0 +1,27 @@ +//// [a.ts] +declare var dec: any, __decorate: any; +@dec export class A { +} + +const o = { a: 1 }; +const y = { ...o }; + + +//// [a.js] +"use strict"; +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.A = void 0; +let A = class A { +}; +A = __decorate([ + dec +], A); +exports.A = A; +const o = { a: 1 }; +const y = Object.assign({}, o); diff --git a/tests/baselines/reference/importCallExpressionErrorInES2015.errors.txt b/tests/baselines/reference/importCallExpressionErrorInES2015.errors.txt index d55a470765854..95937040daa0d 100644 --- a/tests/baselines/reference/importCallExpressionErrorInES2015.errors.txt +++ b/tests/baselines/reference/importCallExpressionErrorInES2015.errors.txt @@ -1,6 +1,6 @@ -tests/cases/conformance/dynamicImport/1.ts(1,1): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'. -tests/cases/conformance/dynamicImport/1.ts(2,10): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'. -tests/cases/conformance/dynamicImport/1.ts(8,16): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'. +tests/cases/conformance/dynamicImport/1.ts(1,1): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. +tests/cases/conformance/dynamicImport/1.ts(2,10): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. +tests/cases/conformance/dynamicImport/1.ts(8,16): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. ==== tests/cases/conformance/dynamicImport/0.ts (0 errors) ==== @@ -9,10 +9,10 @@ tests/cases/conformance/dynamicImport/1.ts(8,16): error TS1323: Dynamic imports ==== tests/cases/conformance/dynamicImport/1.ts (3 errors) ==== import("./0"); ~~~~~~~~~~~~~ -!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'. +!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. var p1 = import("./0"); ~~~~~~~~~~~~~ -!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'. +!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. p1.then(zero => { return zero.foo(); }) @@ -20,5 +20,5 @@ tests/cases/conformance/dynamicImport/1.ts(8,16): error TS1323: Dynamic imports function foo() { const p2 = import("./0"); ~~~~~~~~~~~~~ -!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'. +!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. } \ No newline at end of file diff --git a/tests/baselines/reference/importCallExpressionNestedES2015.errors.txt b/tests/baselines/reference/importCallExpressionNestedES2015.errors.txt index 6a0efe8747b20..4d1f7a55b3ce8 100644 --- a/tests/baselines/reference/importCallExpressionNestedES2015.errors.txt +++ b/tests/baselines/reference/importCallExpressionNestedES2015.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/dynamicImport/index.ts(2,18): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'. -tests/cases/conformance/dynamicImport/index.ts(2,32): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'. +tests/cases/conformance/dynamicImport/index.ts(2,18): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. +tests/cases/conformance/dynamicImport/index.ts(2,32): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. ==== tests/cases/conformance/dynamicImport/foo.ts (0 errors) ==== @@ -9,7 +9,7 @@ tests/cases/conformance/dynamicImport/index.ts(2,32): error TS1323: Dynamic impo async function foo() { return await import((await import("./foo")).default); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'. +!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. ~~~~~~~~~~~~~~~ -!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'. +!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. } \ No newline at end of file diff --git a/tests/baselines/reference/importCallExpressionNestedES20152.errors.txt b/tests/baselines/reference/importCallExpressionNestedES20152.errors.txt index 6a0efe8747b20..4d1f7a55b3ce8 100644 --- a/tests/baselines/reference/importCallExpressionNestedES20152.errors.txt +++ b/tests/baselines/reference/importCallExpressionNestedES20152.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/dynamicImport/index.ts(2,18): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'. -tests/cases/conformance/dynamicImport/index.ts(2,32): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'. +tests/cases/conformance/dynamicImport/index.ts(2,18): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. +tests/cases/conformance/dynamicImport/index.ts(2,32): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. ==== tests/cases/conformance/dynamicImport/foo.ts (0 errors) ==== @@ -9,7 +9,7 @@ tests/cases/conformance/dynamicImport/index.ts(2,32): error TS1323: Dynamic impo async function foo() { return await import((await import("./foo")).default); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'. +!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. ~~~~~~~~~~~~~~~ -!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'. +!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. } \ No newline at end of file diff --git a/tests/baselines/reference/importMeta(module=commonjs,target=es5).errors.txt b/tests/baselines/reference/importMeta(module=commonjs,target=es5).errors.txt index c152da9696952..ba01672d75a8f 100644 --- a/tests/baselines/reference/importMeta(module=commonjs,target=es5).errors.txt +++ b/tests/baselines/reference/importMeta(module=commonjs,target=es5).errors.txt @@ -1,25 +1,25 @@ error TS2468: Cannot find global value 'Promise'. -tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,32): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'. +tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,32): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'. tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,44): error TS2339: Property 'blah' does not exist on type 'ImportMeta'. -tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,51): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'. +tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,51): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'. tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,63): error TS2339: Property 'blue' does not exist on type 'ImportMeta'. -tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,70): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'. -tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(2,1): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'. +tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,70): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'. +tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(2,1): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'. tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(2,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. -tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(11,21): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'. +tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(11,21): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'. tests/cases/conformance/es2019/importMeta/example.ts(2,2): error TS2705: An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. -tests/cases/conformance/es2019/importMeta/example.ts(3,59): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'. -tests/cases/conformance/es2019/importMeta/example.ts(6,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'. +tests/cases/conformance/es2019/importMeta/example.ts(3,59): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'. +tests/cases/conformance/es2019/importMeta/example.ts(6,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'. tests/cases/conformance/es2019/importMeta/example.ts(6,28): error TS2339: Property 'scriptElement' does not exist on type 'ImportMeta'. -tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(1,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'. -tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(2,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'. +tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(1,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'. +tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(2,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'. tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(2,23): error TS17012: 'metal' is not a valid meta-property for keyword 'import'. Did you mean 'meta'? -tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(3,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'. +tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(3,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'. tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(3,23): error TS17012: 'import' is not a valid meta-property for keyword 'import'. Did you mean 'meta'? -tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(1,15): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'. -tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(2,15): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'. +tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(1,15): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'. +tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(2,15): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'. tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(2,22): error TS17012: 'metal' is not a valid meta-property for keyword 'import'. Did you mean 'meta'? -tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,15): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'. +tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,15): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'. tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,22): error TS17012: 'import' is not a valid meta-property for keyword 'import'. Did you mean 'meta'? @@ -31,12 +31,12 @@ tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,22): error TS !!! error TS2705: An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. const response = await fetch(new URL("../hamsters.jpg", import.meta.url).toString()); ~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'. const blob = await response.blob(); const size = import.meta.scriptElement.dataset.size || 300; ~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'. ~~~~~~~~~~~~~ !!! error TS2339: Property 'scriptElement' does not exist on type 'ImportMeta'. @@ -50,48 +50,48 @@ tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,22): error TS ==== tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts (5 errors) ==== export let x = import.meta; ~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'. export let y = import.metal; ~~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'. ~~~~~ !!! error TS17012: 'metal' is not a valid meta-property for keyword 'import'. Did you mean 'meta'? export let z = import.import.import.malkovich; ~~~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'. ~~~~~~ !!! error TS17012: 'import' is not a valid meta-property for keyword 'import'. Did you mean 'meta'? ==== tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts (5 errors) ==== let globalA = import.meta; ~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'. let globalB = import.metal; ~~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'. ~~~~~ !!! error TS17012: 'metal' is not a valid meta-property for keyword 'import'. Did you mean 'meta'? let globalC = import.import.import.malkovich; ~~~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'. ~~~~~~ !!! error TS17012: 'import' is not a valid meta-property for keyword 'import'. Did you mean 'meta'? ==== tests/cases/conformance/es2019/importMeta/assignmentTargets.ts (8 errors) ==== export const foo: ImportMeta = import.meta.blah = import.meta.blue = import.meta; ~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'. ~~~~ !!! error TS2339: Property 'blah' does not exist on type 'ImportMeta'. ~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'. ~~~~ !!! error TS2339: Property 'blue' does not exist on type 'ImportMeta'. ~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'. import.meta = foo; ~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'. ~~~~~~~~~~~ !!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access. @@ -104,4 +104,4 @@ tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,22): error TS const { a, b, c } = import.meta.wellKnownProperty; ~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'. \ No newline at end of file +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'. \ No newline at end of file diff --git a/tests/baselines/reference/importMeta(module=commonjs,target=esnext).errors.txt b/tests/baselines/reference/importMeta(module=commonjs,target=esnext).errors.txt index c152da9696952..ba01672d75a8f 100644 --- a/tests/baselines/reference/importMeta(module=commonjs,target=esnext).errors.txt +++ b/tests/baselines/reference/importMeta(module=commonjs,target=esnext).errors.txt @@ -1,25 +1,25 @@ error TS2468: Cannot find global value 'Promise'. -tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,32): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'. +tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,32): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'. tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,44): error TS2339: Property 'blah' does not exist on type 'ImportMeta'. -tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,51): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'. +tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,51): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'. tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,63): error TS2339: Property 'blue' does not exist on type 'ImportMeta'. -tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,70): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'. -tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(2,1): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'. +tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(1,70): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'. +tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(2,1): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'. tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(2,1): error TS2364: The left-hand side of an assignment expression must be a variable or a property access. -tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(11,21): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'. +tests/cases/conformance/es2019/importMeta/assignmentTargets.ts(11,21): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'. tests/cases/conformance/es2019/importMeta/example.ts(2,2): error TS2705: An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. -tests/cases/conformance/es2019/importMeta/example.ts(3,59): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'. -tests/cases/conformance/es2019/importMeta/example.ts(6,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'. +tests/cases/conformance/es2019/importMeta/example.ts(3,59): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'. +tests/cases/conformance/es2019/importMeta/example.ts(6,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'. tests/cases/conformance/es2019/importMeta/example.ts(6,28): error TS2339: Property 'scriptElement' does not exist on type 'ImportMeta'. -tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(1,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'. -tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(2,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'. +tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(1,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'. +tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(2,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'. tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(2,23): error TS17012: 'metal' is not a valid meta-property for keyword 'import'. Did you mean 'meta'? -tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(3,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'. +tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(3,16): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'. tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts(3,23): error TS17012: 'import' is not a valid meta-property for keyword 'import'. Did you mean 'meta'? -tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(1,15): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'. -tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(2,15): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'. +tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(1,15): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'. +tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(2,15): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'. tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(2,22): error TS17012: 'metal' is not a valid meta-property for keyword 'import'. Did you mean 'meta'? -tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,15): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'. +tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,15): error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'. tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,22): error TS17012: 'import' is not a valid meta-property for keyword 'import'. Did you mean 'meta'? @@ -31,12 +31,12 @@ tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,22): error TS !!! error TS2705: An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your '--lib' option. const response = await fetch(new URL("../hamsters.jpg", import.meta.url).toString()); ~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'. const blob = await response.blob(); const size = import.meta.scriptElement.dataset.size || 300; ~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'. ~~~~~~~~~~~~~ !!! error TS2339: Property 'scriptElement' does not exist on type 'ImportMeta'. @@ -50,48 +50,48 @@ tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,22): error TS ==== tests/cases/conformance/es2019/importMeta/moduleLookingFile01.ts (5 errors) ==== export let x = import.meta; ~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'. export let y = import.metal; ~~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'. ~~~~~ !!! error TS17012: 'metal' is not a valid meta-property for keyword 'import'. Did you mean 'meta'? export let z = import.import.import.malkovich; ~~~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'. ~~~~~~ !!! error TS17012: 'import' is not a valid meta-property for keyword 'import'. Did you mean 'meta'? ==== tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts (5 errors) ==== let globalA = import.meta; ~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'. let globalB = import.metal; ~~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'. ~~~~~ !!! error TS17012: 'metal' is not a valid meta-property for keyword 'import'. Did you mean 'meta'? let globalC = import.import.import.malkovich; ~~~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'. ~~~~~~ !!! error TS17012: 'import' is not a valid meta-property for keyword 'import'. Did you mean 'meta'? ==== tests/cases/conformance/es2019/importMeta/assignmentTargets.ts (8 errors) ==== export const foo: ImportMeta = import.meta.blah = import.meta.blue = import.meta; ~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'. ~~~~ !!! error TS2339: Property 'blah' does not exist on type 'ImportMeta'. ~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'. ~~~~ !!! error TS2339: Property 'blue' does not exist on type 'ImportMeta'. ~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'. import.meta = foo; ~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'. +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'. ~~~~~~~~~~~ !!! error TS2364: The left-hand side of an assignment expression must be a variable or a property access. @@ -104,4 +104,4 @@ tests/cases/conformance/es2019/importMeta/scriptLookingFile01.ts(3,22): error TS const { a, b, c } = import.meta.wellKnownProperty; ~~~~~~~~~~~ -!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', or 'system'. \ No newline at end of file +!!! error TS1343: The 'import.meta' meta-property is only allowed when the '--module' option is 'es2020', 'esnext', 'system', 'node12', or 'nodenext'. \ No newline at end of file diff --git a/tests/baselines/reference/nodeModules1(module=node12).js b/tests/baselines/reference/nodeModules1(module=node12).js new file mode 100644 index 0000000000000..3742bb13c5f2a --- /dev/null +++ b/tests/baselines/reference/nodeModules1(module=node12).js @@ -0,0 +1,58 @@ +//// [tests/cases/conformance/node/nodeModules1.ts] //// + +//// [index.ts] +// cjs format file +const x = 1; +export {x}; +//// [index.ts] +// cjs format file +const x = 1; +export {x}; +//// [index.ts] +// esm format file +const x = 1; +export {x}; +//// [index.ts] +// esm format file +const x = 1; +export {x}; +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} +//// [package.json] +{ +} +//// [package.json] +{ + "type": "module" +} + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +// cjs format file +const x = 1; +exports.x = x; +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +// cjs format file +const x = 1; +exports.x = x; +//// [index.js] +// esm format file +const x = 1; +export { x }; +//// [index.js] +// esm format file +const x = 1; +export { x }; diff --git a/tests/baselines/reference/nodeModules1(module=node12).symbols b/tests/baselines/reference/nodeModules1(module=node12).symbols new file mode 100644 index 0000000000000..e1653429c87db --- /dev/null +++ b/tests/baselines/reference/nodeModules1(module=node12).symbols @@ -0,0 +1,32 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +const x = 1; +>x : Symbol(x, Decl(index.ts, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.ts, 2, 8)) + +=== tests/cases/conformance/node/subfolder2/index.ts === +// cjs format file +const x = 1; +>x : Symbol(x, Decl(index.ts, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.ts, 2, 8)) + +=== tests/cases/conformance/node/subfolder2/another/index.ts === +// esm format file +const x = 1; +>x : Symbol(x, Decl(index.ts, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.ts, 2, 8)) + +=== tests/cases/conformance/node/index.ts === +// esm format file +const x = 1; +>x : Symbol(x, Decl(index.ts, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.ts, 2, 8)) + diff --git a/tests/baselines/reference/nodeModules1(module=node12).types b/tests/baselines/reference/nodeModules1(module=node12).types new file mode 100644 index 0000000000000..1c479a5e7bd48 --- /dev/null +++ b/tests/baselines/reference/nodeModules1(module=node12).types @@ -0,0 +1,36 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + +=== tests/cases/conformance/node/subfolder2/index.ts === +// cjs format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + +=== tests/cases/conformance/node/subfolder2/another/index.ts === +// esm format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + +=== tests/cases/conformance/node/index.ts === +// esm format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + diff --git a/tests/baselines/reference/nodeModules1(module=nodenext).js b/tests/baselines/reference/nodeModules1(module=nodenext).js new file mode 100644 index 0000000000000..3742bb13c5f2a --- /dev/null +++ b/tests/baselines/reference/nodeModules1(module=nodenext).js @@ -0,0 +1,58 @@ +//// [tests/cases/conformance/node/nodeModules1.ts] //// + +//// [index.ts] +// cjs format file +const x = 1; +export {x}; +//// [index.ts] +// cjs format file +const x = 1; +export {x}; +//// [index.ts] +// esm format file +const x = 1; +export {x}; +//// [index.ts] +// esm format file +const x = 1; +export {x}; +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} +//// [package.json] +{ +} +//// [package.json] +{ + "type": "module" +} + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +// cjs format file +const x = 1; +exports.x = x; +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +// cjs format file +const x = 1; +exports.x = x; +//// [index.js] +// esm format file +const x = 1; +export { x }; +//// [index.js] +// esm format file +const x = 1; +export { x }; diff --git a/tests/baselines/reference/nodeModules1(module=nodenext).symbols b/tests/baselines/reference/nodeModules1(module=nodenext).symbols new file mode 100644 index 0000000000000..e1653429c87db --- /dev/null +++ b/tests/baselines/reference/nodeModules1(module=nodenext).symbols @@ -0,0 +1,32 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +const x = 1; +>x : Symbol(x, Decl(index.ts, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.ts, 2, 8)) + +=== tests/cases/conformance/node/subfolder2/index.ts === +// cjs format file +const x = 1; +>x : Symbol(x, Decl(index.ts, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.ts, 2, 8)) + +=== tests/cases/conformance/node/subfolder2/another/index.ts === +// esm format file +const x = 1; +>x : Symbol(x, Decl(index.ts, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.ts, 2, 8)) + +=== tests/cases/conformance/node/index.ts === +// esm format file +const x = 1; +>x : Symbol(x, Decl(index.ts, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.ts, 2, 8)) + diff --git a/tests/baselines/reference/nodeModules1(module=nodenext).types b/tests/baselines/reference/nodeModules1(module=nodenext).types new file mode 100644 index 0000000000000..1c479a5e7bd48 --- /dev/null +++ b/tests/baselines/reference/nodeModules1(module=nodenext).types @@ -0,0 +1,36 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + +=== tests/cases/conformance/node/subfolder2/index.ts === +// cjs format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + +=== tests/cases/conformance/node/subfolder2/another/index.ts === +// esm format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + +=== tests/cases/conformance/node/index.ts === +// esm format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + diff --git a/tests/baselines/reference/nodeModulesDynamicImport(module=node12).js b/tests/baselines/reference/nodeModulesDynamicImport(module=node12).js new file mode 100644 index 0000000000000..71f2979b2146e --- /dev/null +++ b/tests/baselines/reference/nodeModulesDynamicImport(module=node12).js @@ -0,0 +1,39 @@ +//// [tests/cases/conformance/node/nodeModulesDynamicImport.ts] //// + +//// [index.ts] +// cjs format file +export async function main() { + const { readFile } = await import("fs"); +} +//// [index.ts] +// esm format file +export async function main() { + const { readFile } = await import("fs"); +} +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} +//// [types.d.ts] +declare module "fs"; + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.main = void 0; +// cjs format file +async function main() { + const { readFile } = await import("fs"); +} +exports.main = main; +//// [index.js] +// esm format file +export async function main() { + const { readFile } = await import("fs"); +} diff --git a/tests/baselines/reference/nodeModulesDynamicImport(module=node12).symbols b/tests/baselines/reference/nodeModulesDynamicImport(module=node12).symbols new file mode 100644 index 0000000000000..69296bc3fa993 --- /dev/null +++ b/tests/baselines/reference/nodeModulesDynamicImport(module=node12).symbols @@ -0,0 +1,22 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +export async function main() { +>main : Symbol(main, Decl(index.ts, 0, 0)) + + const { readFile } = await import("fs"); +>readFile : Symbol(readFile, Decl(index.ts, 2, 11)) +>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0)) +} +=== tests/cases/conformance/node/index.ts === +// esm format file +export async function main() { +>main : Symbol(main, Decl(index.ts, 0, 0)) + + const { readFile } = await import("fs"); +>readFile : Symbol(readFile, Decl(index.ts, 2, 11)) +>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0)) +} +=== tests/cases/conformance/node/types.d.ts === +declare module "fs"; +>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0)) + diff --git a/tests/baselines/reference/nodeModulesDynamicImport(module=node12).types b/tests/baselines/reference/nodeModulesDynamicImport(module=node12).types new file mode 100644 index 0000000000000..879fb7ca71bf8 --- /dev/null +++ b/tests/baselines/reference/nodeModulesDynamicImport(module=node12).types @@ -0,0 +1,26 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +export async function main() { +>main : () => Promise + + const { readFile } = await import("fs"); +>readFile : any +>await import("fs") : any +>import("fs") : Promise +>"fs" : "fs" +} +=== tests/cases/conformance/node/index.ts === +// esm format file +export async function main() { +>main : () => Promise + + const { readFile } = await import("fs"); +>readFile : any +>await import("fs") : any +>import("fs") : Promise +>"fs" : "fs" +} +=== tests/cases/conformance/node/types.d.ts === +declare module "fs"; +>"fs" : any + diff --git a/tests/baselines/reference/nodeModulesDynamicImport(module=nodenext).js b/tests/baselines/reference/nodeModulesDynamicImport(module=nodenext).js new file mode 100644 index 0000000000000..71f2979b2146e --- /dev/null +++ b/tests/baselines/reference/nodeModulesDynamicImport(module=nodenext).js @@ -0,0 +1,39 @@ +//// [tests/cases/conformance/node/nodeModulesDynamicImport.ts] //// + +//// [index.ts] +// cjs format file +export async function main() { + const { readFile } = await import("fs"); +} +//// [index.ts] +// esm format file +export async function main() { + const { readFile } = await import("fs"); +} +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} +//// [types.d.ts] +declare module "fs"; + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.main = void 0; +// cjs format file +async function main() { + const { readFile } = await import("fs"); +} +exports.main = main; +//// [index.js] +// esm format file +export async function main() { + const { readFile } = await import("fs"); +} diff --git a/tests/baselines/reference/nodeModulesDynamicImport(module=nodenext).symbols b/tests/baselines/reference/nodeModulesDynamicImport(module=nodenext).symbols new file mode 100644 index 0000000000000..69296bc3fa993 --- /dev/null +++ b/tests/baselines/reference/nodeModulesDynamicImport(module=nodenext).symbols @@ -0,0 +1,22 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +export async function main() { +>main : Symbol(main, Decl(index.ts, 0, 0)) + + const { readFile } = await import("fs"); +>readFile : Symbol(readFile, Decl(index.ts, 2, 11)) +>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0)) +} +=== tests/cases/conformance/node/index.ts === +// esm format file +export async function main() { +>main : Symbol(main, Decl(index.ts, 0, 0)) + + const { readFile } = await import("fs"); +>readFile : Symbol(readFile, Decl(index.ts, 2, 11)) +>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0)) +} +=== tests/cases/conformance/node/types.d.ts === +declare module "fs"; +>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0)) + diff --git a/tests/baselines/reference/nodeModulesDynamicImport(module=nodenext).types b/tests/baselines/reference/nodeModulesDynamicImport(module=nodenext).types new file mode 100644 index 0000000000000..879fb7ca71bf8 --- /dev/null +++ b/tests/baselines/reference/nodeModulesDynamicImport(module=nodenext).types @@ -0,0 +1,26 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +export async function main() { +>main : () => Promise + + const { readFile } = await import("fs"); +>readFile : any +>await import("fs") : any +>import("fs") : Promise +>"fs" : "fs" +} +=== tests/cases/conformance/node/index.ts === +// esm format file +export async function main() { +>main : () => Promise + + const { readFile } = await import("fs"); +>readFile : any +>await import("fs") : any +>import("fs") : Promise +>"fs" : "fs" +} +=== tests/cases/conformance/node/types.d.ts === +declare module "fs"; +>"fs" : any + diff --git a/tests/baselines/reference/nodeModulesExportAssignments(module=node12).errors.txt b/tests/baselines/reference/nodeModulesExportAssignments(module=node12).errors.txt new file mode 100644 index 0000000000000..cef2966380663 --- /dev/null +++ b/tests/baselines/reference/nodeModulesExportAssignments(module=node12).errors.txt @@ -0,0 +1,23 @@ +tests/cases/conformance/node/index.ts(3,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. + + +==== tests/cases/conformance/node/subfolder/index.ts (0 errors) ==== + // cjs format file + const a = {}; + export = a; +==== tests/cases/conformance/node/index.ts (1 errors) ==== + // esm format file + const a = {}; + export = a; + ~~~~~~~~~~~ +!!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. +==== tests/cases/conformance/node/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module" + } +==== tests/cases/conformance/node/subfolder/package.json (0 errors) ==== + { + "type": "commonjs" + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesExportAssignments(module=node12).js b/tests/baselines/reference/nodeModulesExportAssignments(module=node12).js new file mode 100644 index 0000000000000..687d129e52e4e --- /dev/null +++ b/tests/baselines/reference/nodeModulesExportAssignments(module=node12).js @@ -0,0 +1,30 @@ +//// [tests/cases/conformance/node/nodeModulesExportAssignments.ts] //// + +//// [index.ts] +// cjs format file +const a = {}; +export = a; +//// [index.ts] +// esm format file +const a = {}; +export = a; +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} + +//// [index.js] +"use strict"; +// cjs format file +const a = {}; +module.exports = a; +//// [index.js] +// esm format file +const a = {}; +export {}; diff --git a/tests/baselines/reference/nodeModulesExportAssignments(module=node12).symbols b/tests/baselines/reference/nodeModulesExportAssignments(module=node12).symbols new file mode 100644 index 0000000000000..4552dd34157ab --- /dev/null +++ b/tests/baselines/reference/nodeModulesExportAssignments(module=node12).symbols @@ -0,0 +1,16 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +const a = {}; +>a : Symbol(a, Decl(index.ts, 1, 5)) + +export = a; +>a : Symbol(a, Decl(index.ts, 1, 5)) + +=== tests/cases/conformance/node/index.ts === +// esm format file +const a = {}; +>a : Symbol(a, Decl(index.ts, 1, 5)) + +export = a; +>a : Symbol(a, Decl(index.ts, 1, 5)) + diff --git a/tests/baselines/reference/nodeModulesExportAssignments(module=node12).types b/tests/baselines/reference/nodeModulesExportAssignments(module=node12).types new file mode 100644 index 0000000000000..73f7e0869eba3 --- /dev/null +++ b/tests/baselines/reference/nodeModulesExportAssignments(module=node12).types @@ -0,0 +1,18 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +const a = {}; +>a : {} +>{} : {} + +export = a; +>a : {} + +=== tests/cases/conformance/node/index.ts === +// esm format file +const a = {}; +>a : {} +>{} : {} + +export = a; +>a : {} + diff --git a/tests/baselines/reference/nodeModulesExportAssignments(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesExportAssignments(module=nodenext).errors.txt new file mode 100644 index 0000000000000..cef2966380663 --- /dev/null +++ b/tests/baselines/reference/nodeModulesExportAssignments(module=nodenext).errors.txt @@ -0,0 +1,23 @@ +tests/cases/conformance/node/index.ts(3,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. + + +==== tests/cases/conformance/node/subfolder/index.ts (0 errors) ==== + // cjs format file + const a = {}; + export = a; +==== tests/cases/conformance/node/index.ts (1 errors) ==== + // esm format file + const a = {}; + export = a; + ~~~~~~~~~~~ +!!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. +==== tests/cases/conformance/node/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module" + } +==== tests/cases/conformance/node/subfolder/package.json (0 errors) ==== + { + "type": "commonjs" + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesExportAssignments(module=nodenext).js b/tests/baselines/reference/nodeModulesExportAssignments(module=nodenext).js new file mode 100644 index 0000000000000..687d129e52e4e --- /dev/null +++ b/tests/baselines/reference/nodeModulesExportAssignments(module=nodenext).js @@ -0,0 +1,30 @@ +//// [tests/cases/conformance/node/nodeModulesExportAssignments.ts] //// + +//// [index.ts] +// cjs format file +const a = {}; +export = a; +//// [index.ts] +// esm format file +const a = {}; +export = a; +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} + +//// [index.js] +"use strict"; +// cjs format file +const a = {}; +module.exports = a; +//// [index.js] +// esm format file +const a = {}; +export {}; diff --git a/tests/baselines/reference/nodeModulesExportAssignments(module=nodenext).symbols b/tests/baselines/reference/nodeModulesExportAssignments(module=nodenext).symbols new file mode 100644 index 0000000000000..4552dd34157ab --- /dev/null +++ b/tests/baselines/reference/nodeModulesExportAssignments(module=nodenext).symbols @@ -0,0 +1,16 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +const a = {}; +>a : Symbol(a, Decl(index.ts, 1, 5)) + +export = a; +>a : Symbol(a, Decl(index.ts, 1, 5)) + +=== tests/cases/conformance/node/index.ts === +// esm format file +const a = {}; +>a : Symbol(a, Decl(index.ts, 1, 5)) + +export = a; +>a : Symbol(a, Decl(index.ts, 1, 5)) + diff --git a/tests/baselines/reference/nodeModulesExportAssignments(module=nodenext).types b/tests/baselines/reference/nodeModulesExportAssignments(module=nodenext).types new file mode 100644 index 0000000000000..73f7e0869eba3 --- /dev/null +++ b/tests/baselines/reference/nodeModulesExportAssignments(module=nodenext).types @@ -0,0 +1,18 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +const a = {}; +>a : {} +>{} : {} + +export = a; +>a : {} + +=== tests/cases/conformance/node/index.ts === +// esm format file +const a = {}; +>a : {} +>{} : {} + +export = a; +>a : {} + diff --git a/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=node12).errors.txt b/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=node12).errors.txt new file mode 100644 index 0000000000000..bcf0d1d592ca8 --- /dev/null +++ b/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=node12).errors.txt @@ -0,0 +1,38 @@ +tests/cases/conformance/node/subfolder/index.ts(2,10): error TS2441: Duplicate identifier 'require'. Compiler reserves name 'require' in top level scope of a module. +tests/cases/conformance/node/subfolder/index.ts(3,7): error TS2441: Duplicate identifier 'exports'. Compiler reserves name 'exports' in top level scope of a module. +tests/cases/conformance/node/subfolder/index.ts(4,7): error TS2725: Class name cannot be 'Object' when targeting ES5 with module Node12. +tests/cases/conformance/node/subfolder/index.ts(5,14): error TS1216: Identifier expected. '__esModule' is reserved as an exported marker when transforming ECMAScript modules. + + +==== tests/cases/conformance/node/subfolder/index.ts (4 errors) ==== + // cjs format file + function require() {} + ~~~~~~~ +!!! error TS2441: Duplicate identifier 'require'. Compiler reserves name 'require' in top level scope of a module. + const exports = {}; + ~~~~~~~ +!!! error TS2441: Duplicate identifier 'exports'. Compiler reserves name 'exports' in top level scope of a module. + class Object {} + ~~~~~~ +!!! error TS2725: Class name cannot be 'Object' when targeting ES5 with module Node12. + export const __esModule = false; + ~~~~~~~~~~ +!!! error TS1216: Identifier expected. '__esModule' is reserved as an exported marker when transforming ECMAScript modules. + export {require, exports, Object}; +==== tests/cases/conformance/node/index.ts (0 errors) ==== + // esm format file + function require() {} + const exports = {}; + class Object {} + export const __esModule = false; + export {require, exports, Object}; +==== tests/cases/conformance/node/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module" + } +==== tests/cases/conformance/node/subfolder/package.json (0 errors) ==== + { + "type": "commonjs" + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=node12).js b/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=node12).js new file mode 100644 index 0000000000000..cc5f8296acfc8 --- /dev/null +++ b/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=node12).js @@ -0,0 +1,48 @@ +//// [tests/cases/conformance/node/nodeModulesGeneratedNameCollisions.ts] //// + +//// [index.ts] +// cjs format file +function require() {} +const exports = {}; +class Object {} +export const __esModule = false; +export {require, exports, Object}; +//// [index.ts] +// esm format file +function require() {} +const exports = {}; +class Object {} +export const __esModule = false; +export {require, exports, Object}; +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Object = exports.exports = exports.require = exports.__esModule = void 0; +// cjs format file +function require() { } +exports.require = require; +const exports = {}; +exports.exports = exports; +class Object { +} +exports.Object = Object; +exports.__esModule = false; +//// [index.js] +// esm format file +function require() { } +const exports = {}; +class Object { +} +export const __esModule = false; +export { require, exports, Object }; diff --git a/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=node12).symbols b/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=node12).symbols new file mode 100644 index 0000000000000..9e967fe93b7a4 --- /dev/null +++ b/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=node12).symbols @@ -0,0 +1,38 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +function require() {} +>require : Symbol(require, Decl(index.ts, 0, 0)) + +const exports = {}; +>exports : Symbol(exports, Decl(index.ts, 2, 5)) + +class Object {} +>Object : Symbol(Object, Decl(index.ts, 2, 19)) + +export const __esModule = false; +>__esModule : Symbol(__esModule, Decl(index.ts, 4, 12)) + +export {require, exports, Object}; +>require : Symbol(require, Decl(index.ts, 5, 8)) +>exports : Symbol(exports, Decl(index.ts, 5, 16)) +>Object : Symbol(Object, Decl(index.ts, 5, 25)) + +=== tests/cases/conformance/node/index.ts === +// esm format file +function require() {} +>require : Symbol(require, Decl(index.ts, 0, 0)) + +const exports = {}; +>exports : Symbol(exports, Decl(index.ts, 2, 5)) + +class Object {} +>Object : Symbol(Object, Decl(index.ts, 2, 19)) + +export const __esModule = false; +>__esModule : Symbol(__esModule, Decl(index.ts, 4, 12)) + +export {require, exports, Object}; +>require : Symbol(require, Decl(index.ts, 5, 8)) +>exports : Symbol(exports, Decl(index.ts, 5, 16)) +>Object : Symbol(Object, Decl(index.ts, 5, 25)) + diff --git a/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=node12).types b/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=node12).types new file mode 100644 index 0000000000000..094de6c869242 --- /dev/null +++ b/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=node12).types @@ -0,0 +1,42 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +function require() {} +>require : () => void + +const exports = {}; +>exports : {} +>{} : {} + +class Object {} +>Object : Object + +export const __esModule = false; +>__esModule : false +>false : false + +export {require, exports, Object}; +>require : () => void +>exports : {} +>Object : typeof Object + +=== tests/cases/conformance/node/index.ts === +// esm format file +function require() {} +>require : () => void + +const exports = {}; +>exports : {} +>{} : {} + +class Object {} +>Object : Object + +export const __esModule = false; +>__esModule : false +>false : false + +export {require, exports, Object}; +>require : () => void +>exports : {} +>Object : typeof Object + diff --git a/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=nodenext).errors.txt new file mode 100644 index 0000000000000..abc62c363a23c --- /dev/null +++ b/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=nodenext).errors.txt @@ -0,0 +1,38 @@ +tests/cases/conformance/node/subfolder/index.ts(2,10): error TS2441: Duplicate identifier 'require'. Compiler reserves name 'require' in top level scope of a module. +tests/cases/conformance/node/subfolder/index.ts(3,7): error TS2441: Duplicate identifier 'exports'. Compiler reserves name 'exports' in top level scope of a module. +tests/cases/conformance/node/subfolder/index.ts(4,7): error TS2725: Class name cannot be 'Object' when targeting ES5 with module NodeNext. +tests/cases/conformance/node/subfolder/index.ts(5,14): error TS1216: Identifier expected. '__esModule' is reserved as an exported marker when transforming ECMAScript modules. + + +==== tests/cases/conformance/node/subfolder/index.ts (4 errors) ==== + // cjs format file + function require() {} + ~~~~~~~ +!!! error TS2441: Duplicate identifier 'require'. Compiler reserves name 'require' in top level scope of a module. + const exports = {}; + ~~~~~~~ +!!! error TS2441: Duplicate identifier 'exports'. Compiler reserves name 'exports' in top level scope of a module. + class Object {} + ~~~~~~ +!!! error TS2725: Class name cannot be 'Object' when targeting ES5 with module NodeNext. + export const __esModule = false; + ~~~~~~~~~~ +!!! error TS1216: Identifier expected. '__esModule' is reserved as an exported marker when transforming ECMAScript modules. + export {require, exports, Object}; +==== tests/cases/conformance/node/index.ts (0 errors) ==== + // esm format file + function require() {} + const exports = {}; + class Object {} + export const __esModule = false; + export {require, exports, Object}; +==== tests/cases/conformance/node/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module" + } +==== tests/cases/conformance/node/subfolder/package.json (0 errors) ==== + { + "type": "commonjs" + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=nodenext).js b/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=nodenext).js new file mode 100644 index 0000000000000..cc5f8296acfc8 --- /dev/null +++ b/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=nodenext).js @@ -0,0 +1,48 @@ +//// [tests/cases/conformance/node/nodeModulesGeneratedNameCollisions.ts] //// + +//// [index.ts] +// cjs format file +function require() {} +const exports = {}; +class Object {} +export const __esModule = false; +export {require, exports, Object}; +//// [index.ts] +// esm format file +function require() {} +const exports = {}; +class Object {} +export const __esModule = false; +export {require, exports, Object}; +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Object = exports.exports = exports.require = exports.__esModule = void 0; +// cjs format file +function require() { } +exports.require = require; +const exports = {}; +exports.exports = exports; +class Object { +} +exports.Object = Object; +exports.__esModule = false; +//// [index.js] +// esm format file +function require() { } +const exports = {}; +class Object { +} +export const __esModule = false; +export { require, exports, Object }; diff --git a/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=nodenext).symbols b/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=nodenext).symbols new file mode 100644 index 0000000000000..9e967fe93b7a4 --- /dev/null +++ b/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=nodenext).symbols @@ -0,0 +1,38 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +function require() {} +>require : Symbol(require, Decl(index.ts, 0, 0)) + +const exports = {}; +>exports : Symbol(exports, Decl(index.ts, 2, 5)) + +class Object {} +>Object : Symbol(Object, Decl(index.ts, 2, 19)) + +export const __esModule = false; +>__esModule : Symbol(__esModule, Decl(index.ts, 4, 12)) + +export {require, exports, Object}; +>require : Symbol(require, Decl(index.ts, 5, 8)) +>exports : Symbol(exports, Decl(index.ts, 5, 16)) +>Object : Symbol(Object, Decl(index.ts, 5, 25)) + +=== tests/cases/conformance/node/index.ts === +// esm format file +function require() {} +>require : Symbol(require, Decl(index.ts, 0, 0)) + +const exports = {}; +>exports : Symbol(exports, Decl(index.ts, 2, 5)) + +class Object {} +>Object : Symbol(Object, Decl(index.ts, 2, 19)) + +export const __esModule = false; +>__esModule : Symbol(__esModule, Decl(index.ts, 4, 12)) + +export {require, exports, Object}; +>require : Symbol(require, Decl(index.ts, 5, 8)) +>exports : Symbol(exports, Decl(index.ts, 5, 16)) +>Object : Symbol(Object, Decl(index.ts, 5, 25)) + diff --git a/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=nodenext).types b/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=nodenext).types new file mode 100644 index 0000000000000..094de6c869242 --- /dev/null +++ b/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=nodenext).types @@ -0,0 +1,42 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +function require() {} +>require : () => void + +const exports = {}; +>exports : {} +>{} : {} + +class Object {} +>Object : Object + +export const __esModule = false; +>__esModule : false +>false : false + +export {require, exports, Object}; +>require : () => void +>exports : {} +>Object : typeof Object + +=== tests/cases/conformance/node/index.ts === +// esm format file +function require() {} +>require : () => void + +const exports = {}; +>exports : {} +>{} : {} + +class Object {} +>Object : Object + +export const __esModule = false; +>__esModule : false +>false : false + +export {require, exports, Object}; +>require : () => void +>exports : {} +>Object : typeof Object + diff --git a/tests/baselines/reference/nodeModulesImportAssignments(module=node12).js b/tests/baselines/reference/nodeModulesImportAssignments(module=node12).js new file mode 100644 index 0000000000000..509c046355ebe --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportAssignments(module=node12).js @@ -0,0 +1,57 @@ +//// [tests/cases/conformance/node/nodeModulesImportAssignments.ts] //// + +//// [index.ts] +// cjs format file +import fs = require("fs"); +fs.readFile; +export import fs2 = require("fs"); +//// [index.ts] +// esm format file +import fs = require("fs"); +fs.readFile; +export import fs2 = require("fs"); +//// [file.ts] +// esm format file +const __require = null; +const _createRequire = null; +import fs = require("fs"); +fs.readFile; +export import fs2 = require("fs"); +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} +//// [types.d.ts] +declare module "fs"; + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +// cjs format file +const fs = require("fs"); +fs.readFile; +exports.fs2 = require("fs"); +//// [index.js] +import { createRequire as _createRequire } from "module"; +const __require = _createRequire(import.meta.url); +// esm format file +const fs = __require("fs"); +fs.readFile; +const fs2 = __require("fs"); +export { fs2 }; +//// [file.js] +import { createRequire as _createRequire_1 } from "module"; +const __require_1 = _createRequire_1(import.meta.url); +// esm format file +const __require = null; +const _createRequire = null; +const fs = __require_1("fs"); +fs.readFile; +const fs2 = __require_1("fs"); +export { fs2 }; diff --git a/tests/baselines/reference/nodeModulesImportAssignments(module=node12).symbols b/tests/baselines/reference/nodeModulesImportAssignments(module=node12).symbols new file mode 100644 index 0000000000000..ae7fbc666da4c --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportAssignments(module=node12).symbols @@ -0,0 +1,43 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +import fs = require("fs"); +>fs : Symbol(fs, Decl(index.ts, 0, 0)) + +fs.readFile; +>fs : Symbol(fs, Decl(index.ts, 0, 0)) + +export import fs2 = require("fs"); +>fs2 : Symbol(fs2, Decl(index.ts, 2, 12)) + +=== tests/cases/conformance/node/index.ts === +// esm format file +import fs = require("fs"); +>fs : Symbol(fs, Decl(index.ts, 0, 0)) + +fs.readFile; +>fs : Symbol(fs, Decl(index.ts, 0, 0)) + +export import fs2 = require("fs"); +>fs2 : Symbol(fs2, Decl(index.ts, 2, 12)) + +=== tests/cases/conformance/node/file.ts === +// esm format file +const __require = null; +>__require : Symbol(__require, Decl(file.ts, 1, 5)) + +const _createRequire = null; +>_createRequire : Symbol(_createRequire, Decl(file.ts, 2, 5)) + +import fs = require("fs"); +>fs : Symbol(fs, Decl(file.ts, 2, 28)) + +fs.readFile; +>fs : Symbol(fs, Decl(file.ts, 2, 28)) + +export import fs2 = require("fs"); +>fs2 : Symbol(fs2, Decl(file.ts, 4, 12)) + +=== tests/cases/conformance/node/types.d.ts === +declare module "fs"; +>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0)) + diff --git a/tests/baselines/reference/nodeModulesImportAssignments(module=node12).types b/tests/baselines/reference/nodeModulesImportAssignments(module=node12).types new file mode 100644 index 0000000000000..21af2cd798f58 --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportAssignments(module=node12).types @@ -0,0 +1,51 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +import fs = require("fs"); +>fs : any + +fs.readFile; +>fs.readFile : any +>fs : any +>readFile : any + +export import fs2 = require("fs"); +>fs2 : any + +=== tests/cases/conformance/node/index.ts === +// esm format file +import fs = require("fs"); +>fs : any + +fs.readFile; +>fs.readFile : any +>fs : any +>readFile : any + +export import fs2 = require("fs"); +>fs2 : any + +=== tests/cases/conformance/node/file.ts === +// esm format file +const __require = null; +>__require : any +>null : null + +const _createRequire = null; +>_createRequire : any +>null : null + +import fs = require("fs"); +>fs : any + +fs.readFile; +>fs.readFile : any +>fs : any +>readFile : any + +export import fs2 = require("fs"); +>fs2 : any + +=== tests/cases/conformance/node/types.d.ts === +declare module "fs"; +>"fs" : any + diff --git a/tests/baselines/reference/nodeModulesImportAssignments(module=nodenext).js b/tests/baselines/reference/nodeModulesImportAssignments(module=nodenext).js new file mode 100644 index 0000000000000..509c046355ebe --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportAssignments(module=nodenext).js @@ -0,0 +1,57 @@ +//// [tests/cases/conformance/node/nodeModulesImportAssignments.ts] //// + +//// [index.ts] +// cjs format file +import fs = require("fs"); +fs.readFile; +export import fs2 = require("fs"); +//// [index.ts] +// esm format file +import fs = require("fs"); +fs.readFile; +export import fs2 = require("fs"); +//// [file.ts] +// esm format file +const __require = null; +const _createRequire = null; +import fs = require("fs"); +fs.readFile; +export import fs2 = require("fs"); +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} +//// [types.d.ts] +declare module "fs"; + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +// cjs format file +const fs = require("fs"); +fs.readFile; +exports.fs2 = require("fs"); +//// [index.js] +import { createRequire as _createRequire } from "module"; +const __require = _createRequire(import.meta.url); +// esm format file +const fs = __require("fs"); +fs.readFile; +const fs2 = __require("fs"); +export { fs2 }; +//// [file.js] +import { createRequire as _createRequire_1 } from "module"; +const __require_1 = _createRequire_1(import.meta.url); +// esm format file +const __require = null; +const _createRequire = null; +const fs = __require_1("fs"); +fs.readFile; +const fs2 = __require_1("fs"); +export { fs2 }; diff --git a/tests/baselines/reference/nodeModulesImportAssignments(module=nodenext).symbols b/tests/baselines/reference/nodeModulesImportAssignments(module=nodenext).symbols new file mode 100644 index 0000000000000..ae7fbc666da4c --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportAssignments(module=nodenext).symbols @@ -0,0 +1,43 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +import fs = require("fs"); +>fs : Symbol(fs, Decl(index.ts, 0, 0)) + +fs.readFile; +>fs : Symbol(fs, Decl(index.ts, 0, 0)) + +export import fs2 = require("fs"); +>fs2 : Symbol(fs2, Decl(index.ts, 2, 12)) + +=== tests/cases/conformance/node/index.ts === +// esm format file +import fs = require("fs"); +>fs : Symbol(fs, Decl(index.ts, 0, 0)) + +fs.readFile; +>fs : Symbol(fs, Decl(index.ts, 0, 0)) + +export import fs2 = require("fs"); +>fs2 : Symbol(fs2, Decl(index.ts, 2, 12)) + +=== tests/cases/conformance/node/file.ts === +// esm format file +const __require = null; +>__require : Symbol(__require, Decl(file.ts, 1, 5)) + +const _createRequire = null; +>_createRequire : Symbol(_createRequire, Decl(file.ts, 2, 5)) + +import fs = require("fs"); +>fs : Symbol(fs, Decl(file.ts, 2, 28)) + +fs.readFile; +>fs : Symbol(fs, Decl(file.ts, 2, 28)) + +export import fs2 = require("fs"); +>fs2 : Symbol(fs2, Decl(file.ts, 4, 12)) + +=== tests/cases/conformance/node/types.d.ts === +declare module "fs"; +>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0)) + diff --git a/tests/baselines/reference/nodeModulesImportAssignments(module=nodenext).types b/tests/baselines/reference/nodeModulesImportAssignments(module=nodenext).types new file mode 100644 index 0000000000000..21af2cd798f58 --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportAssignments(module=nodenext).types @@ -0,0 +1,51 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +import fs = require("fs"); +>fs : any + +fs.readFile; +>fs.readFile : any +>fs : any +>readFile : any + +export import fs2 = require("fs"); +>fs2 : any + +=== tests/cases/conformance/node/index.ts === +// esm format file +import fs = require("fs"); +>fs : any + +fs.readFile; +>fs.readFile : any +>fs : any +>readFile : any + +export import fs2 = require("fs"); +>fs2 : any + +=== tests/cases/conformance/node/file.ts === +// esm format file +const __require = null; +>__require : any +>null : null + +const _createRequire = null; +>_createRequire : any +>null : null + +import fs = require("fs"); +>fs : any + +fs.readFile; +>fs.readFile : any +>fs : any +>readFile : any + +export import fs2 = require("fs"); +>fs2 : any + +=== tests/cases/conformance/node/types.d.ts === +declare module "fs"; +>"fs" : any + diff --git a/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=node12).errors.txt b/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=node12).errors.txt new file mode 100644 index 0000000000000..b4ae0ff6fb045 --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=node12).errors.txt @@ -0,0 +1,36 @@ +tests/cases/conformance/node/subfolder/index.ts(2,9): error TS2343: This syntax requires an imported helper named '__importDefault' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. +tests/cases/conformance/node/subfolder/index.ts(4,1): error TS2343: This syntax requires an imported helper named '__importStar' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. + + +==== tests/cases/conformance/node/subfolder/index.ts (2 errors) ==== + // cjs format file + import {default as _fs} from "fs"; + ~~~~~~~~~~~~~~ +!!! error TS2343: This syntax requires an imported helper named '__importDefault' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. + _fs.readFile; + import * as fs from "fs"; + ~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2343: This syntax requires an imported helper named '__importStar' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. + fs.readFile; +==== tests/cases/conformance/node/index.ts (0 errors) ==== + // esm format file + import {default as _fs} from "fs"; + _fs.readFile; + import * as fs from "fs"; + fs.readFile; +==== tests/cases/conformance/node/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module" + } +==== tests/cases/conformance/node/subfolder/package.json (0 errors) ==== + { + "type": "commonjs" + } +==== tests/cases/conformance/node/types.d.ts (0 errors) ==== + declare module "fs"; + declare module "tslib" { + export {}; + // intentionally missing all helpers + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=node12).js b/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=node12).js new file mode 100644 index 0000000000000..7e7ddefb4008e --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=node12).js @@ -0,0 +1,46 @@ +//// [tests/cases/conformance/node/nodeModulesImportHelpersCollisions.ts] //// + +//// [index.ts] +// cjs format file +import {default as _fs} from "fs"; +_fs.readFile; +import * as fs from "fs"; +fs.readFile; +//// [index.ts] +// esm format file +import {default as _fs} from "fs"; +_fs.readFile; +import * as fs from "fs"; +fs.readFile; +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} +//// [types.d.ts] +declare module "fs"; +declare module "tslib" { + export {}; + // intentionally missing all helpers +} + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const tslib_1 = require("tslib"); +// cjs format file +const fs_1 = (0, tslib_1.__importDefault)(require("fs")); +fs_1.default.readFile; +const fs = (0, tslib_1.__importStar)(require("fs")); +fs.readFile; +//// [index.js] +// esm format file +import { default as _fs } from "fs"; +_fs.readFile; +import * as fs from "fs"; +fs.readFile; diff --git a/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=node12).symbols b/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=node12).symbols new file mode 100644 index 0000000000000..996840abd4e8b --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=node12).symbols @@ -0,0 +1,40 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +import {default as _fs} from "fs"; +>default : Symbol(_fs, Decl(types.d.ts, 0, 0)) +>_fs : Symbol(_fs, Decl(index.ts, 1, 8)) + +_fs.readFile; +>_fs : Symbol(_fs, Decl(index.ts, 1, 8)) + +import * as fs from "fs"; +>fs : Symbol(fs, Decl(index.ts, 3, 6)) + +fs.readFile; +>fs : Symbol(fs, Decl(index.ts, 3, 6)) + +=== tests/cases/conformance/node/index.ts === +// esm format file +import {default as _fs} from "fs"; +>default : Symbol(_fs, Decl(types.d.ts, 0, 0)) +>_fs : Symbol(_fs, Decl(index.ts, 1, 8)) + +_fs.readFile; +>_fs : Symbol(_fs, Decl(index.ts, 1, 8)) + +import * as fs from "fs"; +>fs : Symbol(fs, Decl(index.ts, 3, 6)) + +fs.readFile; +>fs : Symbol(fs, Decl(index.ts, 3, 6)) + +=== tests/cases/conformance/node/types.d.ts === +declare module "fs"; +>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0)) + +declare module "tslib" { +>"tslib" : Symbol("tslib", Decl(types.d.ts, 0, 20)) + + export {}; + // intentionally missing all helpers +} diff --git a/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=node12).types b/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=node12).types new file mode 100644 index 0000000000000..e08e9456be9a5 --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=node12).types @@ -0,0 +1,48 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +import {default as _fs} from "fs"; +>default : any +>_fs : any + +_fs.readFile; +>_fs.readFile : any +>_fs : any +>readFile : any + +import * as fs from "fs"; +>fs : any + +fs.readFile; +>fs.readFile : any +>fs : any +>readFile : any + +=== tests/cases/conformance/node/index.ts === +// esm format file +import {default as _fs} from "fs"; +>default : any +>_fs : any + +_fs.readFile; +>_fs.readFile : any +>_fs : any +>readFile : any + +import * as fs from "fs"; +>fs : any + +fs.readFile; +>fs.readFile : any +>fs : any +>readFile : any + +=== tests/cases/conformance/node/types.d.ts === +declare module "fs"; +>"fs" : any + +declare module "tslib" { +>"tslib" : typeof import("tslib") + + export {}; + // intentionally missing all helpers +} diff --git a/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=nodenext).errors.txt new file mode 100644 index 0000000000000..b4ae0ff6fb045 --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=nodenext).errors.txt @@ -0,0 +1,36 @@ +tests/cases/conformance/node/subfolder/index.ts(2,9): error TS2343: This syntax requires an imported helper named '__importDefault' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. +tests/cases/conformance/node/subfolder/index.ts(4,1): error TS2343: This syntax requires an imported helper named '__importStar' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. + + +==== tests/cases/conformance/node/subfolder/index.ts (2 errors) ==== + // cjs format file + import {default as _fs} from "fs"; + ~~~~~~~~~~~~~~ +!!! error TS2343: This syntax requires an imported helper named '__importDefault' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. + _fs.readFile; + import * as fs from "fs"; + ~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2343: This syntax requires an imported helper named '__importStar' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. + fs.readFile; +==== tests/cases/conformance/node/index.ts (0 errors) ==== + // esm format file + import {default as _fs} from "fs"; + _fs.readFile; + import * as fs from "fs"; + fs.readFile; +==== tests/cases/conformance/node/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module" + } +==== tests/cases/conformance/node/subfolder/package.json (0 errors) ==== + { + "type": "commonjs" + } +==== tests/cases/conformance/node/types.d.ts (0 errors) ==== + declare module "fs"; + declare module "tslib" { + export {}; + // intentionally missing all helpers + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=nodenext).js b/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=nodenext).js new file mode 100644 index 0000000000000..7e7ddefb4008e --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=nodenext).js @@ -0,0 +1,46 @@ +//// [tests/cases/conformance/node/nodeModulesImportHelpersCollisions.ts] //// + +//// [index.ts] +// cjs format file +import {default as _fs} from "fs"; +_fs.readFile; +import * as fs from "fs"; +fs.readFile; +//// [index.ts] +// esm format file +import {default as _fs} from "fs"; +_fs.readFile; +import * as fs from "fs"; +fs.readFile; +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} +//// [types.d.ts] +declare module "fs"; +declare module "tslib" { + export {}; + // intentionally missing all helpers +} + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const tslib_1 = require("tslib"); +// cjs format file +const fs_1 = (0, tslib_1.__importDefault)(require("fs")); +fs_1.default.readFile; +const fs = (0, tslib_1.__importStar)(require("fs")); +fs.readFile; +//// [index.js] +// esm format file +import { default as _fs } from "fs"; +_fs.readFile; +import * as fs from "fs"; +fs.readFile; diff --git a/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=nodenext).symbols b/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=nodenext).symbols new file mode 100644 index 0000000000000..996840abd4e8b --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=nodenext).symbols @@ -0,0 +1,40 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +import {default as _fs} from "fs"; +>default : Symbol(_fs, Decl(types.d.ts, 0, 0)) +>_fs : Symbol(_fs, Decl(index.ts, 1, 8)) + +_fs.readFile; +>_fs : Symbol(_fs, Decl(index.ts, 1, 8)) + +import * as fs from "fs"; +>fs : Symbol(fs, Decl(index.ts, 3, 6)) + +fs.readFile; +>fs : Symbol(fs, Decl(index.ts, 3, 6)) + +=== tests/cases/conformance/node/index.ts === +// esm format file +import {default as _fs} from "fs"; +>default : Symbol(_fs, Decl(types.d.ts, 0, 0)) +>_fs : Symbol(_fs, Decl(index.ts, 1, 8)) + +_fs.readFile; +>_fs : Symbol(_fs, Decl(index.ts, 1, 8)) + +import * as fs from "fs"; +>fs : Symbol(fs, Decl(index.ts, 3, 6)) + +fs.readFile; +>fs : Symbol(fs, Decl(index.ts, 3, 6)) + +=== tests/cases/conformance/node/types.d.ts === +declare module "fs"; +>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0)) + +declare module "tslib" { +>"tslib" : Symbol("tslib", Decl(types.d.ts, 0, 20)) + + export {}; + // intentionally missing all helpers +} diff --git a/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=nodenext).types b/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=nodenext).types new file mode 100644 index 0000000000000..e08e9456be9a5 --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=nodenext).types @@ -0,0 +1,48 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +import {default as _fs} from "fs"; +>default : any +>_fs : any + +_fs.readFile; +>_fs.readFile : any +>_fs : any +>readFile : any + +import * as fs from "fs"; +>fs : any + +fs.readFile; +>fs.readFile : any +>fs : any +>readFile : any + +=== tests/cases/conformance/node/index.ts === +// esm format file +import {default as _fs} from "fs"; +>default : any +>_fs : any + +_fs.readFile; +>_fs.readFile : any +>_fs : any +>readFile : any + +import * as fs from "fs"; +>fs : any + +fs.readFile; +>fs.readFile : any +>fs : any +>readFile : any + +=== tests/cases/conformance/node/types.d.ts === +declare module "fs"; +>"fs" : any + +declare module "tslib" { +>"tslib" : typeof import("tslib") + + export {}; + // intentionally missing all helpers +} diff --git a/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=node12).errors.txt b/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=node12).errors.txt new file mode 100644 index 0000000000000..d2f62391af269 --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=node12).errors.txt @@ -0,0 +1,32 @@ +tests/cases/conformance/node/subfolder/index.ts(2,1): error TS2343: This syntax requires an imported helper named '__exportStar' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. +tests/cases/conformance/node/subfolder/index.ts(3,1): error TS2343: This syntax requires an imported helper named '__importStar' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. + + +==== tests/cases/conformance/node/subfolder/index.ts (2 errors) ==== + // cjs format file + export * from "fs"; + ~~~~~~~~~~~~~~~~~~~ +!!! error TS2343: This syntax requires an imported helper named '__exportStar' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. + export * as fs from "fs"; + ~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2343: This syntax requires an imported helper named '__importStar' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. +==== tests/cases/conformance/node/index.ts (0 errors) ==== + // esm format file + export * from "fs"; + export * as fs from "fs"; +==== tests/cases/conformance/node/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module" + } +==== tests/cases/conformance/node/subfolder/package.json (0 errors) ==== + { + "type": "commonjs" + } +==== tests/cases/conformance/node/types.d.ts (0 errors) ==== + declare module "fs"; + declare module "tslib" { + export {}; + // intentionally missing all helpers + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=node12).js b/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=node12).js new file mode 100644 index 0000000000000..0ba480d137160 --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=node12).js @@ -0,0 +1,39 @@ +//// [tests/cases/conformance/node/nodeModulesImportHelpersCollisions2.ts] //// + +//// [index.ts] +// cjs format file +export * from "fs"; +export * as fs from "fs"; +//// [index.ts] +// esm format file +export * from "fs"; +export * as fs from "fs"; +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} +//// [types.d.ts] +declare module "fs"; +declare module "tslib" { + export {}; + // intentionally missing all helpers +} + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.fs = void 0; +const tslib_1 = require("tslib"); +// cjs format file +(0, tslib_1.__exportStar)(require("fs"), exports); +exports.fs = (0, tslib_1.__importStar)(require("fs")); +//// [index.js] +// esm format file +export * from "fs"; +export * as fs from "fs"; diff --git a/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=node12).symbols b/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=node12).symbols new file mode 100644 index 0000000000000..367ba59adf00f --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=node12).symbols @@ -0,0 +1,22 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +export * from "fs"; +export * as fs from "fs"; +>fs : Symbol(fs, Decl(index.ts, 2, 6)) + +=== tests/cases/conformance/node/index.ts === +// esm format file +export * from "fs"; +export * as fs from "fs"; +>fs : Symbol(fs, Decl(index.ts, 2, 6)) + +=== tests/cases/conformance/node/types.d.ts === +declare module "fs"; +>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0)) + +declare module "tslib" { +>"tslib" : Symbol("tslib", Decl(types.d.ts, 0, 20)) + + export {}; + // intentionally missing all helpers +} diff --git a/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=node12).types b/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=node12).types new file mode 100644 index 0000000000000..6a468baefa7d1 --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=node12).types @@ -0,0 +1,22 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +export * from "fs"; +export * as fs from "fs"; +>fs : any + +=== tests/cases/conformance/node/index.ts === +// esm format file +export * from "fs"; +export * as fs from "fs"; +>fs : any + +=== tests/cases/conformance/node/types.d.ts === +declare module "fs"; +>"fs" : any + +declare module "tslib" { +>"tslib" : typeof import("tslib") + + export {}; + // intentionally missing all helpers +} diff --git a/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=nodenext).errors.txt new file mode 100644 index 0000000000000..d2f62391af269 --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=nodenext).errors.txt @@ -0,0 +1,32 @@ +tests/cases/conformance/node/subfolder/index.ts(2,1): error TS2343: This syntax requires an imported helper named '__exportStar' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. +tests/cases/conformance/node/subfolder/index.ts(3,1): error TS2343: This syntax requires an imported helper named '__importStar' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. + + +==== tests/cases/conformance/node/subfolder/index.ts (2 errors) ==== + // cjs format file + export * from "fs"; + ~~~~~~~~~~~~~~~~~~~ +!!! error TS2343: This syntax requires an imported helper named '__exportStar' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. + export * as fs from "fs"; + ~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2343: This syntax requires an imported helper named '__importStar' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. +==== tests/cases/conformance/node/index.ts (0 errors) ==== + // esm format file + export * from "fs"; + export * as fs from "fs"; +==== tests/cases/conformance/node/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module" + } +==== tests/cases/conformance/node/subfolder/package.json (0 errors) ==== + { + "type": "commonjs" + } +==== tests/cases/conformance/node/types.d.ts (0 errors) ==== + declare module "fs"; + declare module "tslib" { + export {}; + // intentionally missing all helpers + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=nodenext).js b/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=nodenext).js new file mode 100644 index 0000000000000..0ba480d137160 --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=nodenext).js @@ -0,0 +1,39 @@ +//// [tests/cases/conformance/node/nodeModulesImportHelpersCollisions2.ts] //// + +//// [index.ts] +// cjs format file +export * from "fs"; +export * as fs from "fs"; +//// [index.ts] +// esm format file +export * from "fs"; +export * as fs from "fs"; +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} +//// [types.d.ts] +declare module "fs"; +declare module "tslib" { + export {}; + // intentionally missing all helpers +} + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.fs = void 0; +const tslib_1 = require("tslib"); +// cjs format file +(0, tslib_1.__exportStar)(require("fs"), exports); +exports.fs = (0, tslib_1.__importStar)(require("fs")); +//// [index.js] +// esm format file +export * from "fs"; +export * as fs from "fs"; diff --git a/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=nodenext).symbols b/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=nodenext).symbols new file mode 100644 index 0000000000000..367ba59adf00f --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=nodenext).symbols @@ -0,0 +1,22 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +export * from "fs"; +export * as fs from "fs"; +>fs : Symbol(fs, Decl(index.ts, 2, 6)) + +=== tests/cases/conformance/node/index.ts === +// esm format file +export * from "fs"; +export * as fs from "fs"; +>fs : Symbol(fs, Decl(index.ts, 2, 6)) + +=== tests/cases/conformance/node/types.d.ts === +declare module "fs"; +>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0)) + +declare module "tslib" { +>"tslib" : Symbol("tslib", Decl(types.d.ts, 0, 20)) + + export {}; + // intentionally missing all helpers +} diff --git a/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=nodenext).types b/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=nodenext).types new file mode 100644 index 0000000000000..6a468baefa7d1 --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=nodenext).types @@ -0,0 +1,22 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +export * from "fs"; +export * as fs from "fs"; +>fs : any + +=== tests/cases/conformance/node/index.ts === +// esm format file +export * from "fs"; +export * as fs from "fs"; +>fs : any + +=== tests/cases/conformance/node/types.d.ts === +declare module "fs"; +>"fs" : any + +declare module "tslib" { +>"tslib" : typeof import("tslib") + + export {}; + // intentionally missing all helpers +} diff --git a/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=node12).errors.txt b/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=node12).errors.txt new file mode 100644 index 0000000000000..d511944f39332 --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=node12).errors.txt @@ -0,0 +1,27 @@ +tests/cases/conformance/node/subfolder/index.ts(2,9): error TS2343: This syntax requires an imported helper named '__importDefault' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. + + +==== tests/cases/conformance/node/subfolder/index.ts (1 errors) ==== + // cjs format file + export {default} from "fs"; + ~~~~~~~ +!!! error TS2343: This syntax requires an imported helper named '__importDefault' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. +==== tests/cases/conformance/node/index.ts (0 errors) ==== + // esm format file + export {default} from "fs"; +==== tests/cases/conformance/node/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module" + } +==== tests/cases/conformance/node/subfolder/package.json (0 errors) ==== + { + "type": "commonjs" + } +==== tests/cases/conformance/node/types.d.ts (0 errors) ==== + declare module "fs"; + declare module "tslib" { + export {}; + // intentionally missing all helpers + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=node12).js b/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=node12).js new file mode 100644 index 0000000000000..b541d7253fb3d --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=node12).js @@ -0,0 +1,38 @@ +//// [tests/cases/conformance/node/nodeModulesImportHelpersCollisions3.ts] //// + +//// [index.ts] +// cjs format file +export {default} from "fs"; +//// [index.ts] +// esm format file +export {default} from "fs"; +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} +//// [types.d.ts] +declare module "fs"; +declare module "tslib" { + export {}; + // intentionally missing all helpers +} + +//// [index.js] +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = void 0; +// cjs format file +var fs_1 = require("fs"); +Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(fs_1).default; } }); +//// [index.js] +// esm format file +export { default } from "fs"; diff --git a/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=node12).symbols b/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=node12).symbols new file mode 100644 index 0000000000000..aec1d32dab1d4 --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=node12).symbols @@ -0,0 +1,20 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +export {default} from "fs"; +>default : Symbol(default, Decl(index.ts, 1, 8)) + +=== tests/cases/conformance/node/index.ts === +// esm format file +export {default} from "fs"; +>default : Symbol(default, Decl(index.ts, 1, 8)) + +=== tests/cases/conformance/node/types.d.ts === +declare module "fs"; +>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0)) + +declare module "tslib" { +>"tslib" : Symbol("tslib", Decl(types.d.ts, 0, 20)) + + export {}; + // intentionally missing all helpers +} diff --git a/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=node12).types b/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=node12).types new file mode 100644 index 0000000000000..eef93356ac7bc --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=node12).types @@ -0,0 +1,20 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +export {default} from "fs"; +>default : any + +=== tests/cases/conformance/node/index.ts === +// esm format file +export {default} from "fs"; +>default : any + +=== tests/cases/conformance/node/types.d.ts === +declare module "fs"; +>"fs" : any + +declare module "tslib" { +>"tslib" : typeof import("tslib") + + export {}; + // intentionally missing all helpers +} diff --git a/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=nodenext).errors.txt new file mode 100644 index 0000000000000..d511944f39332 --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=nodenext).errors.txt @@ -0,0 +1,27 @@ +tests/cases/conformance/node/subfolder/index.ts(2,9): error TS2343: This syntax requires an imported helper named '__importDefault' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. + + +==== tests/cases/conformance/node/subfolder/index.ts (1 errors) ==== + // cjs format file + export {default} from "fs"; + ~~~~~~~ +!!! error TS2343: This syntax requires an imported helper named '__importDefault' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. +==== tests/cases/conformance/node/index.ts (0 errors) ==== + // esm format file + export {default} from "fs"; +==== tests/cases/conformance/node/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module" + } +==== tests/cases/conformance/node/subfolder/package.json (0 errors) ==== + { + "type": "commonjs" + } +==== tests/cases/conformance/node/types.d.ts (0 errors) ==== + declare module "fs"; + declare module "tslib" { + export {}; + // intentionally missing all helpers + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=nodenext).js b/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=nodenext).js new file mode 100644 index 0000000000000..b541d7253fb3d --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=nodenext).js @@ -0,0 +1,38 @@ +//// [tests/cases/conformance/node/nodeModulesImportHelpersCollisions3.ts] //// + +//// [index.ts] +// cjs format file +export {default} from "fs"; +//// [index.ts] +// esm format file +export {default} from "fs"; +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} +//// [types.d.ts] +declare module "fs"; +declare module "tslib" { + export {}; + // intentionally missing all helpers +} + +//// [index.js] +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = void 0; +// cjs format file +var fs_1 = require("fs"); +Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(fs_1).default; } }); +//// [index.js] +// esm format file +export { default } from "fs"; diff --git a/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=nodenext).symbols b/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=nodenext).symbols new file mode 100644 index 0000000000000..aec1d32dab1d4 --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=nodenext).symbols @@ -0,0 +1,20 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +export {default} from "fs"; +>default : Symbol(default, Decl(index.ts, 1, 8)) + +=== tests/cases/conformance/node/index.ts === +// esm format file +export {default} from "fs"; +>default : Symbol(default, Decl(index.ts, 1, 8)) + +=== tests/cases/conformance/node/types.d.ts === +declare module "fs"; +>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0)) + +declare module "tslib" { +>"tslib" : Symbol("tslib", Decl(types.d.ts, 0, 20)) + + export {}; + // intentionally missing all helpers +} diff --git a/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=nodenext).types b/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=nodenext).types new file mode 100644 index 0000000000000..eef93356ac7bc --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=nodenext).types @@ -0,0 +1,20 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +export {default} from "fs"; +>default : any + +=== tests/cases/conformance/node/index.ts === +// esm format file +export {default} from "fs"; +>default : any + +=== tests/cases/conformance/node/types.d.ts === +declare module "fs"; +>"fs" : any + +declare module "tslib" { +>"tslib" : typeof import("tslib") + + export {}; + // intentionally missing all helpers +} diff --git a/tests/baselines/reference/nodeModulesImportMeta(module=node12).errors.txt b/tests/baselines/reference/nodeModulesImportMeta(module=node12).errors.txt new file mode 100644 index 0000000000000..3a7d1f4399ab7 --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportMeta(module=node12).errors.txt @@ -0,0 +1,23 @@ +tests/cases/conformance/node/subfolder/index.ts(2,11): error TS1434: The 'import.meta' meta-property is not allowed in files which will build into CommonJS output. + + +==== tests/cases/conformance/node/subfolder/index.ts (1 errors) ==== + // cjs format file + const x = import.meta.url; + ~~~~~~~~~~~ +!!! error TS1434: The 'import.meta' meta-property is not allowed in files which will build into CommonJS output. + export {x}; +==== tests/cases/conformance/node/index.ts (0 errors) ==== + // esm format file + const x = import.meta.url; + export {x}; +==== tests/cases/conformance/node/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module" + } +==== tests/cases/conformance/node/subfolder/package.json (0 errors) ==== + { + "type": "commonjs" + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesImportMeta(module=node12).js b/tests/baselines/reference/nodeModulesImportMeta(module=node12).js new file mode 100644 index 0000000000000..a236853057399 --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportMeta(module=node12).js @@ -0,0 +1,32 @@ +//// [tests/cases/conformance/node/nodeModulesImportMeta.ts] //// + +//// [index.ts] +// cjs format file +const x = import.meta.url; +export {x}; +//// [index.ts] +// esm format file +const x = import.meta.url; +export {x}; +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +// cjs format file +const x = import.meta.url; +exports.x = x; +//// [index.js] +// esm format file +const x = import.meta.url; +export { x }; diff --git a/tests/baselines/reference/nodeModulesImportMeta(module=node12).symbols b/tests/baselines/reference/nodeModulesImportMeta(module=node12).symbols new file mode 100644 index 0000000000000..4f320ebf560e0 --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportMeta(module=node12).symbols @@ -0,0 +1,20 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +const x = import.meta.url; +>x : Symbol(x, Decl(index.ts, 1, 5)) +>import.meta.url : Symbol(ImportMeta.url, Decl(lib.dom.d.ts, --, --)) +>url : Symbol(ImportMeta.url, Decl(lib.dom.d.ts, --, --)) + +export {x}; +>x : Symbol(x, Decl(index.ts, 2, 8)) + +=== tests/cases/conformance/node/index.ts === +// esm format file +const x = import.meta.url; +>x : Symbol(x, Decl(index.ts, 1, 5)) +>import.meta.url : Symbol(ImportMeta.url, Decl(lib.dom.d.ts, --, --)) +>url : Symbol(ImportMeta.url, Decl(lib.dom.d.ts, --, --)) + +export {x}; +>x : Symbol(x, Decl(index.ts, 2, 8)) + diff --git a/tests/baselines/reference/nodeModulesImportMeta(module=node12).types b/tests/baselines/reference/nodeModulesImportMeta(module=node12).types new file mode 100644 index 0000000000000..6f64dc2b5faa6 --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportMeta(module=node12).types @@ -0,0 +1,24 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +const x = import.meta.url; +>x : string +>import.meta.url : string +>import.meta : ImportMeta +>meta : any +>url : string + +export {x}; +>x : string + +=== tests/cases/conformance/node/index.ts === +// esm format file +const x = import.meta.url; +>x : string +>import.meta.url : string +>import.meta : ImportMeta +>meta : any +>url : string + +export {x}; +>x : string + diff --git a/tests/baselines/reference/nodeModulesImportMeta(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesImportMeta(module=nodenext).errors.txt new file mode 100644 index 0000000000000..3a7d1f4399ab7 --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportMeta(module=nodenext).errors.txt @@ -0,0 +1,23 @@ +tests/cases/conformance/node/subfolder/index.ts(2,11): error TS1434: The 'import.meta' meta-property is not allowed in files which will build into CommonJS output. + + +==== tests/cases/conformance/node/subfolder/index.ts (1 errors) ==== + // cjs format file + const x = import.meta.url; + ~~~~~~~~~~~ +!!! error TS1434: The 'import.meta' meta-property is not allowed in files which will build into CommonJS output. + export {x}; +==== tests/cases/conformance/node/index.ts (0 errors) ==== + // esm format file + const x = import.meta.url; + export {x}; +==== tests/cases/conformance/node/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module" + } +==== tests/cases/conformance/node/subfolder/package.json (0 errors) ==== + { + "type": "commonjs" + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesImportMeta(module=nodenext).js b/tests/baselines/reference/nodeModulesImportMeta(module=nodenext).js new file mode 100644 index 0000000000000..a236853057399 --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportMeta(module=nodenext).js @@ -0,0 +1,32 @@ +//// [tests/cases/conformance/node/nodeModulesImportMeta.ts] //// + +//// [index.ts] +// cjs format file +const x = import.meta.url; +export {x}; +//// [index.ts] +// esm format file +const x = import.meta.url; +export {x}; +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +// cjs format file +const x = import.meta.url; +exports.x = x; +//// [index.js] +// esm format file +const x = import.meta.url; +export { x }; diff --git a/tests/baselines/reference/nodeModulesImportMeta(module=nodenext).symbols b/tests/baselines/reference/nodeModulesImportMeta(module=nodenext).symbols new file mode 100644 index 0000000000000..4f320ebf560e0 --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportMeta(module=nodenext).symbols @@ -0,0 +1,20 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +const x = import.meta.url; +>x : Symbol(x, Decl(index.ts, 1, 5)) +>import.meta.url : Symbol(ImportMeta.url, Decl(lib.dom.d.ts, --, --)) +>url : Symbol(ImportMeta.url, Decl(lib.dom.d.ts, --, --)) + +export {x}; +>x : Symbol(x, Decl(index.ts, 2, 8)) + +=== tests/cases/conformance/node/index.ts === +// esm format file +const x = import.meta.url; +>x : Symbol(x, Decl(index.ts, 1, 5)) +>import.meta.url : Symbol(ImportMeta.url, Decl(lib.dom.d.ts, --, --)) +>url : Symbol(ImportMeta.url, Decl(lib.dom.d.ts, --, --)) + +export {x}; +>x : Symbol(x, Decl(index.ts, 2, 8)) + diff --git a/tests/baselines/reference/nodeModulesImportMeta(module=nodenext).types b/tests/baselines/reference/nodeModulesImportMeta(module=nodenext).types new file mode 100644 index 0000000000000..6f64dc2b5faa6 --- /dev/null +++ b/tests/baselines/reference/nodeModulesImportMeta(module=nodenext).types @@ -0,0 +1,24 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +const x = import.meta.url; +>x : string +>import.meta.url : string +>import.meta : ImportMeta +>meta : any +>url : string + +export {x}; +>x : string + +=== tests/cases/conformance/node/index.ts === +// esm format file +const x = import.meta.url; +>x : string +>import.meta.url : string +>import.meta : ImportMeta +>meta : any +>url : string + +export {x}; +>x : string + diff --git a/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=node12).errors.txt b/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=node12).errors.txt new file mode 100644 index 0000000000000..2569b342924dc --- /dev/null +++ b/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=node12).errors.txt @@ -0,0 +1,43 @@ +tests/cases/conformance/node/index.ts(3,22): error TS1435: Module './index.js' 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/subfolder/index.ts(2,17): error TS1435: Module '../index.js' 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/subfolder/index.ts(3,22): error TS1435: Module '../index.js' 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/subfolder/index.ts (2 errors) ==== + // cjs format file + import {h} from "../index.js"; + ~~~~~~~~~~~~~ +!!! error TS1435: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. + import mod = require("../index.js"); + ~~~~~~~~~~~~~ +!!! error TS1435: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. + import {f as _f} from "./index.js"; + import mod2 = require("./index.js"); + export async function f() { + const mod3 = await import ("../index.js"); + const mod4 = await import ("./index.js"); + h(); + } +==== tests/cases/conformance/node/index.ts (1 errors) ==== + // esm format file + import {h as _h} from "./index.js"; + import mod = require("./index.js"); + ~~~~~~~~~~~~ +!!! error TS1435: Module './index.js' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. + import {f} from "./subfolder/index.js"; + import mod2 = require("./subfolder/index.js"); + export async function h() { + const mod3 = await import ("./index.js"); + const mod4 = await import ("./subfolder/index.js"); + f(); + } +==== tests/cases/conformance/node/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module" + } +==== tests/cases/conformance/node/subfolder/package.json (0 errors) ==== + { + "type": "commonjs" + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=node12).js b/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=node12).js new file mode 100644 index 0000000000000..c37ce0438cba1 --- /dev/null +++ b/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=node12).js @@ -0,0 +1,54 @@ +//// [tests/cases/conformance/node/nodeModulesSynchronousCallErrors.ts] //// + +//// [index.ts] +// cjs format file +import {h} from "../index.js"; +import mod = require("../index.js"); +import {f as _f} from "./index.js"; +import mod2 = require("./index.js"); +export async function f() { + const mod3 = await import ("../index.js"); + const mod4 = await import ("./index.js"); + h(); +} +//// [index.ts] +// esm format file +import {h as _h} from "./index.js"; +import mod = require("./index.js"); +import {f} from "./subfolder/index.js"; +import mod2 = require("./subfolder/index.js"); +export async function h() { + const mod3 = await import ("./index.js"); + const mod4 = await import ("./subfolder/index.js"); + f(); +} +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} + +//// [index.js] +import { f } from "./subfolder/index.js"; +export async function h() { + const mod3 = await import("./index.js"); + const mod4 = await import("./subfolder/index.js"); + f(); +} +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.f = void 0; +// cjs format file +const index_js_1 = require("../index.js"); +async function f() { + const mod3 = await import("../index.js"); + const mod4 = await import("./index.js"); + (0, index_js_1.h)(); +} +exports.f = f; diff --git a/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=node12).symbols b/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=node12).symbols new file mode 100644 index 0000000000000..8b03ab0af9f41 --- /dev/null +++ b/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=node12).symbols @@ -0,0 +1,58 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +import {h} from "../index.js"; +>h : Symbol(h, Decl(index.ts, 1, 8)) + +import mod = require("../index.js"); +>mod : Symbol(mod, Decl(index.ts, 1, 30)) + +import {f as _f} from "./index.js"; +>f : Symbol(f, Decl(index.ts, 4, 36)) +>_f : Symbol(_f, Decl(index.ts, 3, 8)) + +import mod2 = require("./index.js"); +>mod2 : Symbol(mod2, Decl(index.ts, 3, 35)) + +export async function f() { +>f : Symbol(f, Decl(index.ts, 4, 36)) + + const mod3 = await import ("../index.js"); +>mod3 : Symbol(mod3, Decl(index.ts, 6, 9)) +>"../index.js" : Symbol(mod, Decl(index.ts, 0, 0)) + + const mod4 = await import ("./index.js"); +>mod4 : Symbol(mod4, Decl(index.ts, 7, 9)) +>"./index.js" : Symbol(mod2, Decl(index.ts, 0, 0)) + + h(); +>h : Symbol(h, Decl(index.ts, 1, 8)) +} +=== tests/cases/conformance/node/index.ts === +// esm format file +import {h as _h} from "./index.js"; +>h : Symbol(h, Decl(index.ts, 4, 46)) +>_h : Symbol(_h, Decl(index.ts, 1, 8)) + +import mod = require("./index.js"); +>mod : Symbol(mod, Decl(index.ts, 1, 35)) + +import {f} from "./subfolder/index.js"; +>f : Symbol(f, Decl(index.ts, 3, 8)) + +import mod2 = require("./subfolder/index.js"); +>mod2 : Symbol(mod2, Decl(index.ts, 3, 39)) + +export async function h() { +>h : Symbol(h, Decl(index.ts, 4, 46)) + + const mod3 = await import ("./index.js"); +>mod3 : Symbol(mod3, Decl(index.ts, 6, 9)) +>"./index.js" : Symbol(mod, Decl(index.ts, 0, 0)) + + const mod4 = await import ("./subfolder/index.js"); +>mod4 : Symbol(mod4, Decl(index.ts, 7, 9)) +>"./subfolder/index.js" : Symbol(mod2, Decl(index.ts, 0, 0)) + + f(); +>f : Symbol(f, Decl(index.ts, 3, 8)) +} diff --git a/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=node12).types b/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=node12).types new file mode 100644 index 0000000000000..8ca6d52152161 --- /dev/null +++ b/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=node12).types @@ -0,0 +1,68 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +import {h} from "../index.js"; +>h : () => Promise + +import mod = require("../index.js"); +>mod : typeof mod + +import {f as _f} from "./index.js"; +>f : () => Promise +>_f : () => Promise + +import mod2 = require("./index.js"); +>mod2 : typeof mod2 + +export async function f() { +>f : () => Promise + + const mod3 = await import ("../index.js"); +>mod3 : typeof mod +>await import ("../index.js") : typeof mod +>import ("../index.js") : Promise +>"../index.js" : "../index.js" + + const mod4 = await import ("./index.js"); +>mod4 : typeof mod2 +>await import ("./index.js") : typeof mod2 +>import ("./index.js") : Promise +>"./index.js" : "./index.js" + + h(); +>h() : Promise +>h : () => Promise +} +=== tests/cases/conformance/node/index.ts === +// esm format file +import {h as _h} from "./index.js"; +>h : () => Promise +>_h : () => Promise + +import mod = require("./index.js"); +>mod : typeof mod + +import {f} from "./subfolder/index.js"; +>f : () => Promise + +import mod2 = require("./subfolder/index.js"); +>mod2 : typeof mod2 + +export async function h() { +>h : () => Promise + + const mod3 = await import ("./index.js"); +>mod3 : typeof mod +>await import ("./index.js") : typeof mod +>import ("./index.js") : Promise +>"./index.js" : "./index.js" + + const mod4 = await import ("./subfolder/index.js"); +>mod4 : typeof mod2 +>await import ("./subfolder/index.js") : typeof mod2 +>import ("./subfolder/index.js") : Promise +>"./subfolder/index.js" : "./subfolder/index.js" + + f(); +>f() : Promise +>f : () => Promise +} diff --git a/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=nodenext).errors.txt new file mode 100644 index 0000000000000..2569b342924dc --- /dev/null +++ b/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=nodenext).errors.txt @@ -0,0 +1,43 @@ +tests/cases/conformance/node/index.ts(3,22): error TS1435: Module './index.js' 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/subfolder/index.ts(2,17): error TS1435: Module '../index.js' 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/subfolder/index.ts(3,22): error TS1435: Module '../index.js' 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/subfolder/index.ts (2 errors) ==== + // cjs format file + import {h} from "../index.js"; + ~~~~~~~~~~~~~ +!!! error TS1435: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. + import mod = require("../index.js"); + ~~~~~~~~~~~~~ +!!! error TS1435: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. + import {f as _f} from "./index.js"; + import mod2 = require("./index.js"); + export async function f() { + const mod3 = await import ("../index.js"); + const mod4 = await import ("./index.js"); + h(); + } +==== tests/cases/conformance/node/index.ts (1 errors) ==== + // esm format file + import {h as _h} from "./index.js"; + import mod = require("./index.js"); + ~~~~~~~~~~~~ +!!! error TS1435: Module './index.js' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. + import {f} from "./subfolder/index.js"; + import mod2 = require("./subfolder/index.js"); + export async function h() { + const mod3 = await import ("./index.js"); + const mod4 = await import ("./subfolder/index.js"); + f(); + } +==== tests/cases/conformance/node/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module" + } +==== tests/cases/conformance/node/subfolder/package.json (0 errors) ==== + { + "type": "commonjs" + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=nodenext).js b/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=nodenext).js new file mode 100644 index 0000000000000..c37ce0438cba1 --- /dev/null +++ b/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=nodenext).js @@ -0,0 +1,54 @@ +//// [tests/cases/conformance/node/nodeModulesSynchronousCallErrors.ts] //// + +//// [index.ts] +// cjs format file +import {h} from "../index.js"; +import mod = require("../index.js"); +import {f as _f} from "./index.js"; +import mod2 = require("./index.js"); +export async function f() { + const mod3 = await import ("../index.js"); + const mod4 = await import ("./index.js"); + h(); +} +//// [index.ts] +// esm format file +import {h as _h} from "./index.js"; +import mod = require("./index.js"); +import {f} from "./subfolder/index.js"; +import mod2 = require("./subfolder/index.js"); +export async function h() { + const mod3 = await import ("./index.js"); + const mod4 = await import ("./subfolder/index.js"); + f(); +} +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} + +//// [index.js] +import { f } from "./subfolder/index.js"; +export async function h() { + const mod3 = await import("./index.js"); + const mod4 = await import("./subfolder/index.js"); + f(); +} +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.f = void 0; +// cjs format file +const index_js_1 = require("../index.js"); +async function f() { + const mod3 = await import("../index.js"); + const mod4 = await import("./index.js"); + (0, index_js_1.h)(); +} +exports.f = f; diff --git a/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=nodenext).symbols b/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=nodenext).symbols new file mode 100644 index 0000000000000..8b03ab0af9f41 --- /dev/null +++ b/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=nodenext).symbols @@ -0,0 +1,58 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +import {h} from "../index.js"; +>h : Symbol(h, Decl(index.ts, 1, 8)) + +import mod = require("../index.js"); +>mod : Symbol(mod, Decl(index.ts, 1, 30)) + +import {f as _f} from "./index.js"; +>f : Symbol(f, Decl(index.ts, 4, 36)) +>_f : Symbol(_f, Decl(index.ts, 3, 8)) + +import mod2 = require("./index.js"); +>mod2 : Symbol(mod2, Decl(index.ts, 3, 35)) + +export async function f() { +>f : Symbol(f, Decl(index.ts, 4, 36)) + + const mod3 = await import ("../index.js"); +>mod3 : Symbol(mod3, Decl(index.ts, 6, 9)) +>"../index.js" : Symbol(mod, Decl(index.ts, 0, 0)) + + const mod4 = await import ("./index.js"); +>mod4 : Symbol(mod4, Decl(index.ts, 7, 9)) +>"./index.js" : Symbol(mod2, Decl(index.ts, 0, 0)) + + h(); +>h : Symbol(h, Decl(index.ts, 1, 8)) +} +=== tests/cases/conformance/node/index.ts === +// esm format file +import {h as _h} from "./index.js"; +>h : Symbol(h, Decl(index.ts, 4, 46)) +>_h : Symbol(_h, Decl(index.ts, 1, 8)) + +import mod = require("./index.js"); +>mod : Symbol(mod, Decl(index.ts, 1, 35)) + +import {f} from "./subfolder/index.js"; +>f : Symbol(f, Decl(index.ts, 3, 8)) + +import mod2 = require("./subfolder/index.js"); +>mod2 : Symbol(mod2, Decl(index.ts, 3, 39)) + +export async function h() { +>h : Symbol(h, Decl(index.ts, 4, 46)) + + const mod3 = await import ("./index.js"); +>mod3 : Symbol(mod3, Decl(index.ts, 6, 9)) +>"./index.js" : Symbol(mod, Decl(index.ts, 0, 0)) + + const mod4 = await import ("./subfolder/index.js"); +>mod4 : Symbol(mod4, Decl(index.ts, 7, 9)) +>"./subfolder/index.js" : Symbol(mod2, Decl(index.ts, 0, 0)) + + f(); +>f : Symbol(f, Decl(index.ts, 3, 8)) +} diff --git a/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=nodenext).types b/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=nodenext).types new file mode 100644 index 0000000000000..8ca6d52152161 --- /dev/null +++ b/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=nodenext).types @@ -0,0 +1,68 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +import {h} from "../index.js"; +>h : () => Promise + +import mod = require("../index.js"); +>mod : typeof mod + +import {f as _f} from "./index.js"; +>f : () => Promise +>_f : () => Promise + +import mod2 = require("./index.js"); +>mod2 : typeof mod2 + +export async function f() { +>f : () => Promise + + const mod3 = await import ("../index.js"); +>mod3 : typeof mod +>await import ("../index.js") : typeof mod +>import ("../index.js") : Promise +>"../index.js" : "../index.js" + + const mod4 = await import ("./index.js"); +>mod4 : typeof mod2 +>await import ("./index.js") : typeof mod2 +>import ("./index.js") : Promise +>"./index.js" : "./index.js" + + h(); +>h() : Promise +>h : () => Promise +} +=== tests/cases/conformance/node/index.ts === +// esm format file +import {h as _h} from "./index.js"; +>h : () => Promise +>_h : () => Promise + +import mod = require("./index.js"); +>mod : typeof mod + +import {f} from "./subfolder/index.js"; +>f : () => Promise + +import mod2 = require("./subfolder/index.js"); +>mod2 : typeof mod2 + +export async function h() { +>h : () => Promise + + const mod3 = await import ("./index.js"); +>mod3 : typeof mod +>await import ("./index.js") : typeof mod +>import ("./index.js") : Promise +>"./index.js" : "./index.js" + + const mod4 = await import ("./subfolder/index.js"); +>mod4 : typeof mod2 +>await import ("./subfolder/index.js") : typeof mod2 +>import ("./subfolder/index.js") : Promise +>"./subfolder/index.js" : "./subfolder/index.js" + + f(); +>f() : Promise +>f : () => Promise +} diff --git a/tests/baselines/reference/nodeModulesTopLevelAwait(module=node12).errors.txt b/tests/baselines/reference/nodeModulesTopLevelAwait(module=node12).errors.txt new file mode 100644 index 0000000000000..3a02a6e3d3737 --- /dev/null +++ b/tests/baselines/reference/nodeModulesTopLevelAwait(module=node12).errors.txt @@ -0,0 +1,34 @@ +tests/cases/conformance/node/index.ts(2,11): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +tests/cases/conformance/node/index.ts(4,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +tests/cases/conformance/node/subfolder/index.ts(2,11): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +tests/cases/conformance/node/subfolder/index.ts(4,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. + + +==== tests/cases/conformance/node/subfolder/index.ts (2 errors) ==== + // cjs format file + const x = await 1; + ~~~~~ +!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. + export {x}; + for await (const y of []) {} + ~~~~~ +!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +==== tests/cases/conformance/node/index.ts (2 errors) ==== + // esm format file + const x = await 1; + ~~~~~ +!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. + export {x}; + for await (const y of []) {} + ~~~~~ +!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +==== tests/cases/conformance/node/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module" + } +==== tests/cases/conformance/node/subfolder/package.json (0 errors) ==== + { + "type": "commonjs" + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesTopLevelAwait(module=node12).js b/tests/baselines/reference/nodeModulesTopLevelAwait(module=node12).js new file mode 100644 index 0000000000000..ee36688fe4cf3 --- /dev/null +++ b/tests/baselines/reference/nodeModulesTopLevelAwait(module=node12).js @@ -0,0 +1,36 @@ +//// [tests/cases/conformance/node/nodeModulesTopLevelAwait.ts] //// + +//// [index.ts] +// cjs format file +const x = await 1; +export {x}; +for await (const y of []) {} +//// [index.ts] +// esm format file +const x = await 1; +export {x}; +for await (const y of []) {} +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +// cjs format file +const x = await 1; +exports.x = x; +for await (const y of []) { } +//// [index.js] +// esm format file +const x = await 1; +export { x }; +for await (const y of []) { } diff --git a/tests/baselines/reference/nodeModulesTopLevelAwait(module=node12).symbols b/tests/baselines/reference/nodeModulesTopLevelAwait(module=node12).symbols new file mode 100644 index 0000000000000..624f09cb77334 --- /dev/null +++ b/tests/baselines/reference/nodeModulesTopLevelAwait(module=node12).symbols @@ -0,0 +1,22 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +const x = await 1; +>x : Symbol(x, Decl(index.ts, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.ts, 2, 8)) + +for await (const y of []) {} +>y : Symbol(y, Decl(index.ts, 3, 16)) + +=== tests/cases/conformance/node/index.ts === +// esm format file +const x = await 1; +>x : Symbol(x, Decl(index.ts, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.ts, 2, 8)) + +for await (const y of []) {} +>y : Symbol(y, Decl(index.ts, 3, 16)) + diff --git a/tests/baselines/reference/nodeModulesTopLevelAwait(module=node12).types b/tests/baselines/reference/nodeModulesTopLevelAwait(module=node12).types new file mode 100644 index 0000000000000..ae8108f4020a2 --- /dev/null +++ b/tests/baselines/reference/nodeModulesTopLevelAwait(module=node12).types @@ -0,0 +1,28 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +const x = await 1; +>x : 1 +>await 1 : 1 +>1 : 1 + +export {x}; +>x : 1 + +for await (const y of []) {} +>y : any +>[] : undefined[] + +=== tests/cases/conformance/node/index.ts === +// esm format file +const x = await 1; +>x : 1 +>await 1 : 1 +>1 : 1 + +export {x}; +>x : 1 + +for await (const y of []) {} +>y : any +>[] : undefined[] + diff --git a/tests/baselines/reference/nodeModulesTopLevelAwait(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesTopLevelAwait(module=nodenext).errors.txt new file mode 100644 index 0000000000000..a8fa4008492e7 --- /dev/null +++ b/tests/baselines/reference/nodeModulesTopLevelAwait(module=nodenext).errors.txt @@ -0,0 +1,28 @@ +tests/cases/conformance/node/subfolder/index.ts(2,11): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +tests/cases/conformance/node/subfolder/index.ts(4,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. + + +==== tests/cases/conformance/node/subfolder/index.ts (2 errors) ==== + // cjs format file + const x = await 1; + ~~~~~ +!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. + export {x}; + for await (const y of []) {} + ~~~~~ +!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +==== tests/cases/conformance/node/index.ts (0 errors) ==== + // esm format file + const x = await 1; + export {x}; + for await (const y of []) {} +==== tests/cases/conformance/node/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module" + } +==== tests/cases/conformance/node/subfolder/package.json (0 errors) ==== + { + "type": "commonjs" + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesTopLevelAwait(module=nodenext).js b/tests/baselines/reference/nodeModulesTopLevelAwait(module=nodenext).js new file mode 100644 index 0000000000000..ee36688fe4cf3 --- /dev/null +++ b/tests/baselines/reference/nodeModulesTopLevelAwait(module=nodenext).js @@ -0,0 +1,36 @@ +//// [tests/cases/conformance/node/nodeModulesTopLevelAwait.ts] //// + +//// [index.ts] +// cjs format file +const x = await 1; +export {x}; +for await (const y of []) {} +//// [index.ts] +// esm format file +const x = await 1; +export {x}; +for await (const y of []) {} +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +// cjs format file +const x = await 1; +exports.x = x; +for await (const y of []) { } +//// [index.js] +// esm format file +const x = await 1; +export { x }; +for await (const y of []) { } diff --git a/tests/baselines/reference/nodeModulesTopLevelAwait(module=nodenext).symbols b/tests/baselines/reference/nodeModulesTopLevelAwait(module=nodenext).symbols new file mode 100644 index 0000000000000..624f09cb77334 --- /dev/null +++ b/tests/baselines/reference/nodeModulesTopLevelAwait(module=nodenext).symbols @@ -0,0 +1,22 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +const x = await 1; +>x : Symbol(x, Decl(index.ts, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.ts, 2, 8)) + +for await (const y of []) {} +>y : Symbol(y, Decl(index.ts, 3, 16)) + +=== tests/cases/conformance/node/index.ts === +// esm format file +const x = await 1; +>x : Symbol(x, Decl(index.ts, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.ts, 2, 8)) + +for await (const y of []) {} +>y : Symbol(y, Decl(index.ts, 3, 16)) + diff --git a/tests/baselines/reference/nodeModulesTopLevelAwait(module=nodenext).types b/tests/baselines/reference/nodeModulesTopLevelAwait(module=nodenext).types new file mode 100644 index 0000000000000..ae8108f4020a2 --- /dev/null +++ b/tests/baselines/reference/nodeModulesTopLevelAwait(module=nodenext).types @@ -0,0 +1,28 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +const x = await 1; +>x : 1 +>await 1 : 1 +>1 : 1 + +export {x}; +>x : 1 + +for await (const y of []) {} +>y : any +>[] : undefined[] + +=== tests/cases/conformance/node/index.ts === +// esm format file +const x = await 1; +>x : 1 +>await 1 : 1 +>1 : 1 + +export {x}; +>x : 1 + +for await (const y of []) {} +>y : any +>[] : undefined[] + diff --git a/tests/baselines/reference/parser.forAwait.es2018.errors.txt b/tests/baselines/reference/parser.forAwait.es2018.errors.txt index cc70ef748d0a7..5969e4b6256b1 100644 --- a/tests/baselines/reference/parser.forAwait.es2018.errors.txt +++ b/tests/baselines/reference/parser.forAwait.es2018.errors.txt @@ -8,10 +8,10 @@ tests/cases/conformance/parser/ecmascript2018/forAwait/inFunctionDeclWithExprIsE tests/cases/conformance/parser/ecmascript2018/forAwait/inGeneratorWithDeclIsError.ts(3,9): error TS1103: 'for await' loops are only allowed within async functions and at the top levels of modules. tests/cases/conformance/parser/ecmascript2018/forAwait/inGeneratorWithExprIsError.ts(3,9): error TS1103: 'for await' loops are only allowed within async functions and at the top levels of modules. tests/cases/conformance/parser/ecmascript2018/forAwait/topLevelWithDeclIsError.ts(1,5): error TS1431: 'for await' loops are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module. -tests/cases/conformance/parser/ecmascript2018/forAwait/topLevelWithDeclIsError.ts(1,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher. +tests/cases/conformance/parser/ecmascript2018/forAwait/topLevelWithDeclIsError.ts(1,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. tests/cases/conformance/parser/ecmascript2018/forAwait/topLevelWithDeclIsError.ts(1,23): error TS2304: Cannot find name 'y'. tests/cases/conformance/parser/ecmascript2018/forAwait/topLevelWithExprIsError.ts(1,5): error TS1431: 'for await' loops are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module. -tests/cases/conformance/parser/ecmascript2018/forAwait/topLevelWithExprIsError.ts(1,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher. +tests/cases/conformance/parser/ecmascript2018/forAwait/topLevelWithExprIsError.ts(1,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. tests/cases/conformance/parser/ecmascript2018/forAwait/topLevelWithExprIsError.ts(1,12): error TS2304: Cannot find name 'x'. tests/cases/conformance/parser/ecmascript2018/forAwait/topLevelWithExprIsError.ts(1,17): error TS2304: Cannot find name 'y'. @@ -21,7 +21,7 @@ tests/cases/conformance/parser/ecmascript2018/forAwait/topLevelWithExprIsError.t ~~~~~ !!! error TS1431: 'for await' loops are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module. ~~~~~ -!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher. +!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. ~ !!! error TS2304: Cannot find name 'y'. } @@ -30,7 +30,7 @@ tests/cases/conformance/parser/ecmascript2018/forAwait/topLevelWithExprIsError.t ~~~~~ !!! error TS1431: 'for await' loops are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module. ~~~~~ -!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher. +!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. ~ !!! error TS2304: Cannot find name 'x'. ~ diff --git a/tests/baselines/reference/topLevelAwait.1(module=esnext,target=es2015).errors.txt b/tests/baselines/reference/topLevelAwait.1(module=esnext,target=es2015).errors.txt index aeea7ac641fa2..1c4b9b820b7ed 100644 --- a/tests/baselines/reference/topLevelAwait.1(module=esnext,target=es2015).errors.txt +++ b/tests/baselines/reference/topLevelAwait.1(module=esnext,target=es2015).errors.txt @@ -1,13 +1,13 @@ -tests/cases/conformance/externalModules/index.ts(2,1): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher. -tests/cases/conformance/externalModules/index.ts(46,3): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher. -tests/cases/conformance/externalModules/other.ts(9,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher. +tests/cases/conformance/externalModules/index.ts(2,1): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +tests/cases/conformance/externalModules/index.ts(46,3): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +tests/cases/conformance/externalModules/other.ts(9,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. ==== tests/cases/conformance/externalModules/index.ts (2 errors) ==== export const x = 1; await x; ~~~~~ -!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher. +!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. // reparse element access as await await [x]; @@ -53,7 +53,7 @@ tests/cases/conformance/externalModules/other.ts(9,5): error TS1432: Top-level ' declare const dec: any; @(await dec) ~~~~~ -!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher. +!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. class C { } @@ -84,7 +84,7 @@ tests/cases/conformance/externalModules/other.ts(9,5): error TS1432: Top-level ' for await (const item of arr) { ~~~~~ -!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher. +!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. item; } \ No newline at end of file diff --git a/tests/baselines/reference/topLevelAwait.1(module=system,target=es2015).errors.txt b/tests/baselines/reference/topLevelAwait.1(module=system,target=es2015).errors.txt index aeea7ac641fa2..1c4b9b820b7ed 100644 --- a/tests/baselines/reference/topLevelAwait.1(module=system,target=es2015).errors.txt +++ b/tests/baselines/reference/topLevelAwait.1(module=system,target=es2015).errors.txt @@ -1,13 +1,13 @@ -tests/cases/conformance/externalModules/index.ts(2,1): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher. -tests/cases/conformance/externalModules/index.ts(46,3): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher. -tests/cases/conformance/externalModules/other.ts(9,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher. +tests/cases/conformance/externalModules/index.ts(2,1): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +tests/cases/conformance/externalModules/index.ts(46,3): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +tests/cases/conformance/externalModules/other.ts(9,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. ==== tests/cases/conformance/externalModules/index.ts (2 errors) ==== export const x = 1; await x; ~~~~~ -!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher. +!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. // reparse element access as await await [x]; @@ -53,7 +53,7 @@ tests/cases/conformance/externalModules/other.ts(9,5): error TS1432: Top-level ' declare const dec: any; @(await dec) ~~~~~ -!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher. +!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. class C { } @@ -84,7 +84,7 @@ tests/cases/conformance/externalModules/other.ts(9,5): error TS1432: Top-level ' for await (const item of arr) { ~~~~~ -!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher. +!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. item; } \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.errors.txt b/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.errors.txt index 812f55c9be313..f4a6f8d147e63 100644 --- a/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.errors.txt +++ b/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.errors.txt @@ -1,6 +1,6 @@ -error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'esnext'. +error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'esnext', 'node12', 'nodenext'. -!!! error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'esnext'. +!!! error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'esnext', 'node12', 'nodenext'. ==== file.ts (0 errors) ==== \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.oldTranspile.errors.txt b/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.oldTranspile.errors.txt index 812f55c9be313..f4a6f8d147e63 100644 --- a/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.oldTranspile.errors.txt +++ b/tests/baselines/reference/transpile/Report an error when compiler-options module-kind is out-of-range.oldTranspile.errors.txt @@ -1,6 +1,6 @@ -error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'esnext'. +error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'esnext', 'node12', 'nodenext'. -!!! error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'esnext'. +!!! error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'esnext', 'node12', 'nodenext'. ==== file.ts (0 errors) ==== \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.errors.txt b/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.errors.txt index 812f55c9be313..f4a6f8d147e63 100644 --- a/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.errors.txt +++ b/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.errors.txt @@ -1,6 +1,6 @@ -error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'esnext'. +error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'esnext', 'node12', 'nodenext'. -!!! error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'esnext'. +!!! error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'esnext', 'node12', 'nodenext'. ==== file.ts (0 errors) ==== \ No newline at end of file diff --git a/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.oldTranspile.errors.txt b/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.oldTranspile.errors.txt index 812f55c9be313..f4a6f8d147e63 100644 --- a/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.oldTranspile.errors.txt +++ b/tests/baselines/reference/transpile/Report an error when compiler-options target-script is out-of-range.oldTranspile.errors.txt @@ -1,6 +1,6 @@ -error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'esnext'. +error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'esnext', 'node12', 'nodenext'. -!!! error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'esnext'. +!!! error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'es2020', 'esnext', 'node12', 'nodenext'. ==== file.ts (0 errors) ==== \ No newline at end of file diff --git a/tests/baselines/reference/tsbuild/resolveJsonModule/initial-build/files-containing-json-file.js b/tests/baselines/reference/tsbuild/resolveJsonModule/initial-build/files-containing-json-file.js index 024124e902148..761d5e83e6cf7 100644 --- a/tests/baselines/reference/tsbuild/resolveJsonModule/initial-build/files-containing-json-file.js +++ b/tests/baselines/reference/tsbuild/resolveJsonModule/initial-build/files-containing-json-file.js @@ -62,7 +62,7 @@ Output:: [12:00:00 AM] Building project '/src/tsconfig_withFiles.json'... lib/lib.d.ts - Default library + Default library for target 'es3' src/src/hello.json Imported via "./hello.json" from file 'src/src/index.ts' Part of 'files' list in tsconfig.json diff --git a/tests/baselines/reference/tsbuild/resolveJsonModule/initial-build/include-and-files.js b/tests/baselines/reference/tsbuild/resolveJsonModule/initial-build/include-and-files.js index 9eac7d6941344..a39c9a4c2fc9c 100644 --- a/tests/baselines/reference/tsbuild/resolveJsonModule/initial-build/include-and-files.js +++ b/tests/baselines/reference/tsbuild/resolveJsonModule/initial-build/include-and-files.js @@ -65,7 +65,7 @@ Output:: [12:00:00 AM] Building project '/src/tsconfig_withIncludeAndFiles.json'... lib/lib.d.ts - Default library + Default library for target 'es3' src/src/hello.json Part of 'files' list in tsconfig.json Imported via "./hello.json" from file 'src/src/index.ts' diff --git a/tests/baselines/reference/tsbuild/resolveJsonModule/initial-build/include-of-json-along-with-other-include-and-file-name-matches-ts-file.js b/tests/baselines/reference/tsbuild/resolveJsonModule/initial-build/include-of-json-along-with-other-include-and-file-name-matches-ts-file.js index ee56612178f8f..a9f864eb9ce7d 100644 --- a/tests/baselines/reference/tsbuild/resolveJsonModule/initial-build/include-of-json-along-with-other-include-and-file-name-matches-ts-file.js +++ b/tests/baselines/reference/tsbuild/resolveJsonModule/initial-build/include-of-json-along-with-other-include-and-file-name-matches-ts-file.js @@ -60,7 +60,7 @@ Output:: [12:00:00 AM] Building project '/src/tsconfig_withIncludeOfJson.json'... lib/lib.d.ts - Default library + Default library for target 'es3' src/src/index.json Imported via "./index.json" from file 'src/src/index.ts' Matched by include pattern 'src/**/*.json' in 'src/tsconfig_withIncludeOfJson.json' diff --git a/tests/baselines/reference/tsbuild/resolveJsonModule/initial-build/include-of-json-along-with-other-include.js b/tests/baselines/reference/tsbuild/resolveJsonModule/initial-build/include-of-json-along-with-other-include.js index 8416d4d8875ff..13c1edfb0227c 100644 --- a/tests/baselines/reference/tsbuild/resolveJsonModule/initial-build/include-of-json-along-with-other-include.js +++ b/tests/baselines/reference/tsbuild/resolveJsonModule/initial-build/include-of-json-along-with-other-include.js @@ -62,7 +62,7 @@ Output:: [12:00:00 AM] Building project '/src/tsconfig_withIncludeOfJson.json'... lib/lib.d.ts - Default library + Default library for target 'es3' src/src/hello.json Imported via "./hello.json" from file 'src/src/index.ts' Matched by include pattern 'src/**/*.json' in 'src/tsconfig_withIncludeOfJson.json' diff --git a/tests/baselines/reference/tsbuild/resolveJsonModule/initial-build/include-only.js b/tests/baselines/reference/tsbuild/resolveJsonModule/initial-build/include-only.js index 8e4f275ff5480..c865691cdf6bd 100644 --- a/tests/baselines/reference/tsbuild/resolveJsonModule/initial-build/include-only.js +++ b/tests/baselines/reference/tsbuild/resolveJsonModule/initial-build/include-only.js @@ -67,7 +67,7 @@ Output::    ~~~~~~~~~~~~~~ lib/lib.d.ts - Default library + Default library for target 'es3' src/src/hello.json Imported via "./hello.json" from file 'src/src/index.ts' src/src/index.ts diff --git a/tests/baselines/reference/tsbuild/resolveJsonModule/initial-build/sourcemap.js b/tests/baselines/reference/tsbuild/resolveJsonModule/initial-build/sourcemap.js index ea38f8b9f90b7..6c6c6d52e20ea 100644 --- a/tests/baselines/reference/tsbuild/resolveJsonModule/initial-build/sourcemap.js +++ b/tests/baselines/reference/tsbuild/resolveJsonModule/initial-build/sourcemap.js @@ -62,7 +62,7 @@ Output:: [12:01:00 AM] Building project '/src/tsconfig_withFiles.json'... lib/lib.d.ts - Default library + Default library for target 'es3' src/src/hello.json Imported via "./hello.json" from file 'src/src/index.ts' Part of 'files' list in tsconfig.json diff --git a/tests/baselines/reference/tsbuild/sample1/initial-build/explainFiles.js b/tests/baselines/reference/tsbuild/sample1/initial-build/explainFiles.js index ea560846edfb0..74c2463e3a398 100644 --- a/tests/baselines/reference/tsbuild/sample1/initial-build/explainFiles.js +++ b/tests/baselines/reference/tsbuild/sample1/initial-build/explainFiles.js @@ -108,7 +108,7 @@ Output:: [12:01:00 AM] Building project '/src/core/tsconfig.json'... lib/lib.d.ts - Default library + Default library for target 'es3' src/core/anotherModule.ts Matched by include pattern '**/*' in 'src/core/tsconfig.json' src/core/index.ts @@ -120,7 +120,7 @@ src/core/some_decl.d.ts [12:01:00 AM] Building project '/src/logic/tsconfig.json'... lib/lib.d.ts - Default library + Default library for target 'es3' src/core/index.d.ts Imported via '../core/index' from file 'src/logic/index.ts' File is output of project reference source 'src/core/index.ts' @@ -134,7 +134,7 @@ src/logic/index.ts [12:01:00 AM] Building project '/src/tests/tsconfig.json'... lib/lib.d.ts - Default library + Default library for target 'es3' src/core/index.d.ts Imported via '../core/index' from file 'src/tests/index.ts' File is output of project reference source 'src/core/index.ts' @@ -450,7 +450,7 @@ Output:: [12:04:00 AM] Updating unchanged output timestamps of project '/src/core/tsconfig.json'... lib/lib.d.ts - Default library + Default library for target 'es3' src/core/anotherModule.ts Matched by include pattern '**/*' in 'src/core/tsconfig.json' src/core/index.ts @@ -462,7 +462,7 @@ src/core/some_decl.d.ts [12:04:00 AM] Building project '/src/logic/tsconfig.json'... lib/lib.d.ts - Default library + Default library for target 'es3' src/core/index.d.ts Imported via '../core/index' from file 'src/logic/index.ts' File is output of project reference source 'src/core/index.ts' @@ -476,7 +476,7 @@ src/logic/index.ts [12:04:00 AM] Building project '/src/tests/tsconfig.json'... lib/lib.d.ts - Default library + Default library for target 'es3' src/core/index.d.ts Imported via '../core/index' from file 'src/tests/index.ts' File is output of project reference source 'src/core/index.ts' @@ -753,7 +753,7 @@ Output:: [12:07:00 AM] Updating unchanged output timestamps of project '/src/core/tsconfig.json'... lib/lib.d.ts - Default library + Default library for target 'es3' src/core/anotherModule.ts Matched by include pattern '**/*' in 'src/core/tsconfig.json' src/core/index.ts diff --git a/tests/baselines/reference/tsc/runWithoutArgs/initial-build/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped-when-host-can't-provide-terminal-width.js b/tests/baselines/reference/tsc/runWithoutArgs/initial-build/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped-when-host-can't-provide-terminal-width.js index d58956b4597bb..f92c3a45152d6 100644 --- a/tests/baselines/reference/tsc/runWithoutArgs/initial-build/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped-when-host-can't-provide-terminal-width.js +++ b/tests/baselines/reference/tsc/runWithoutArgs/initial-build/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped-when-host-can't-provide-terminal-width.js @@ -73,7 +73,7 @@ default: ES3 --module, -m Specify what module code is generated. -one of: none, commonjs, amd, system, umd, es6, es2015, es2020, esnext +one of: none, commonjs, amd, system, umd, es6, es2015, es2020, esnext, node12, nodenext --lib Specify a set of bundled library declaration files that describe the target runtime environment. diff --git a/tests/baselines/reference/tsc/runWithoutArgs/initial-build/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped.js b/tests/baselines/reference/tsc/runWithoutArgs/initial-build/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped.js index d58956b4597bb..f92c3a45152d6 100644 --- a/tests/baselines/reference/tsc/runWithoutArgs/initial-build/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped.js +++ b/tests/baselines/reference/tsc/runWithoutArgs/initial-build/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped.js @@ -73,7 +73,7 @@ default: ES3 --module, -m Specify what module code is generated. -one of: none, commonjs, amd, system, umd, es6, es2015, es2020, esnext +one of: none, commonjs, amd, system, umd, es6, es2015, es2020, esnext, node12, nodenext --lib Specify a set of bundled library declaration files that describe the target runtime environment. diff --git a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/jsxImportSource-option-changed.js b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/jsxImportSource-option-changed.js index 3338233b3909f..eaf8dd041f62b 100644 --- a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/jsxImportSource-option-changed.js +++ b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/jsxImportSource-option-changed.js @@ -52,7 +52,7 @@ Output:: File is matched by 'files' list specified here. ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' node_modules/react/jsx-Runtime/index.d.ts Part of 'files' list in tsconfig.json Imported via "react/jsx-runtime" from file 'index.tsx' with packageId 'react/jsx-runtime/index.d.ts@0.0.1' to import 'jsx' and 'jsxs' factory functions diff --git a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-Windows-style-drive-root-is-lowercase.js b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-Windows-style-drive-root-is-lowercase.js index ba9744a17f4cb..33e472c837816 100644 --- a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-Windows-style-drive-root-is-lowercase.js +++ b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-Windows-style-drive-root-is-lowercase.js @@ -36,7 +36,7 @@ Output:: [12:00:17 AM] Starting compilation in watch mode... a/lib/lib.d.ts - Default library + Default library for target 'es3' project/a.ts Matched by include pattern '**/*' in 'project/tsconfig.json' Imported via "C://project/a" from file 'project/b.ts' @@ -119,7 +119,7 @@ Output:: [12:00:25 AM] File change detected. Starting incremental compilation... a/lib/lib.d.ts - Default library + Default library for target 'es3' project/a.ts Matched by include pattern '**/*' in 'project/tsconfig.json' Imported via "C://project/a" from file 'project/b.ts' diff --git a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-Windows-style-drive-root-is-uppercase.js b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-Windows-style-drive-root-is-uppercase.js index ab1200f39b443..e8961da542b86 100644 --- a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-Windows-style-drive-root-is-uppercase.js +++ b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-Windows-style-drive-root-is-uppercase.js @@ -36,7 +36,7 @@ Output:: [12:00:17 AM] Starting compilation in watch mode... a/lib/lib.d.ts - Default library + Default library for target 'es3' project/a.ts Matched by include pattern '**/*' in 'project/tsconfig.json' Imported via "C://project/a" from file 'project/b.ts' @@ -119,7 +119,7 @@ Output:: [12:00:25 AM] File change detected. Starting incremental compilation... a/lib/lib.d.ts - Default library + Default library for target 'es3' project/a.ts Matched by include pattern '**/*' in 'project/tsconfig.json' Imported via "C://project/a" from file 'project/b.ts' diff --git a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-both-directory-symlink-target-and-import-match-disk.js b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-both-directory-symlink-target-and-import-match-disk.js index bd308029095cf..634c9ca43fadb 100644 --- a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-both-directory-symlink-target-and-import-match-disk.js +++ b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-both-directory-symlink-target-and-import-match-disk.js @@ -37,7 +37,7 @@ Output:: [12:00:27 AM] Starting compilation in watch mode... ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' XY/a.ts Imported via "./XY/a" from file 'b.ts' Matched by include pattern '**/*' in 'tsconfig.json' @@ -147,7 +147,7 @@ Output:: [12:00:33 AM] File change detected. Starting incremental compilation... ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' XY/a.ts Imported via "./XY/a" from file 'b.ts' Matched by include pattern '**/*' in 'tsconfig.json' diff --git a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-both-file-symlink-target-and-import-match-disk.js b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-both-file-symlink-target-and-import-match-disk.js index 9aba67160c4de..53467069a4612 100644 --- a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-both-file-symlink-target-and-import-match-disk.js +++ b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-both-file-symlink-target-and-import-match-disk.js @@ -37,7 +37,7 @@ Output:: [12:00:25 AM] Starting compilation in watch mode... ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' XY.ts Matched by include pattern '**/*' in 'tsconfig.json' Imported via "./XY" from file 'b.ts' @@ -135,7 +135,7 @@ Output:: [12:00:35 AM] File change detected. Starting incremental compilation... ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' XY.ts Matched by include pattern '**/*' in 'tsconfig.json' Imported via "./XY" from file 'b.ts' diff --git a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-directory-symlink-target-matches-disk-but-import-does-not.js b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-directory-symlink-target-matches-disk-but-import-does-not.js index a471f439dcc4e..b847f8fdb410d 100644 --- a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-directory-symlink-target-matches-disk-but-import-does-not.js +++ b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-directory-symlink-target-matches-disk-but-import-does-not.js @@ -37,7 +37,7 @@ Output:: [12:00:27 AM] Starting compilation in watch mode... ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' XY/a.ts Imported via "./XY/a" from file 'b.ts' Matched by include pattern '**/*' in 'tsconfig.json' @@ -147,7 +147,7 @@ Output:: [12:00:33 AM] File change detected. Starting incremental compilation... ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' XY/a.ts Imported via "./XY/a" from file 'b.ts' Matched by include pattern '**/*' in 'tsconfig.json' diff --git a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-file-symlink-target-matches-disk-but-import-does-not.js b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-file-symlink-target-matches-disk-but-import-does-not.js index 87d683f1bd9ed..094ce2ca94265 100644 --- a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-file-symlink-target-matches-disk-but-import-does-not.js +++ b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-file-symlink-target-matches-disk-but-import-does-not.js @@ -37,7 +37,7 @@ Output:: [12:00:25 AM] Starting compilation in watch mode... ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' XY.ts Matched by include pattern '**/*' in 'tsconfig.json' Imported via "./XY" from file 'b.ts' @@ -135,7 +135,7 @@ Output:: [12:00:35 AM] File change detected. Starting incremental compilation... ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' XY.ts Matched by include pattern '**/*' in 'tsconfig.json' Imported via "./XY" from file 'b.ts' diff --git a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-import,-directory-symlink-target,-and-disk-are-all-different.js b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-import,-directory-symlink-target,-and-disk-are-all-different.js index 69b82b693d6af..c9f4403e401f2 100644 --- a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-import,-directory-symlink-target,-and-disk-are-all-different.js +++ b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-import,-directory-symlink-target,-and-disk-are-all-different.js @@ -42,7 +42,7 @@ Output::    ~~~~~~~~ ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' link/a.ts Imported via "./link/a" from file 'b.ts' b.ts @@ -158,7 +158,7 @@ Output::    ~~~~~~~~ ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' link/a.ts Imported via "./link/a" from file 'b.ts' b.ts diff --git a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-import,-file-symlink-target,-and-disk-are-all-different.js b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-import,-file-symlink-target,-and-disk-are-all-different.js index 432449b6e600c..39c9167334e37 100644 --- a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-import,-file-symlink-target,-and-disk-are-all-different.js +++ b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-import,-file-symlink-target,-and-disk-are-all-different.js @@ -42,7 +42,7 @@ Output::    ~~~~~~ ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' XY.ts Matched by include pattern '**/*' in 'tsconfig.json' link.ts @@ -148,7 +148,7 @@ Output::    ~~~~~~ ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' XY.ts Matched by include pattern '**/*' in 'tsconfig.json' link.ts diff --git a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-import-and-directory-symlink-target-agree-but-do-not-match-disk.js b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-import-and-directory-symlink-target-agree-but-do-not-match-disk.js index f0d6ddc84018d..a3571bb39360c 100644 --- a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-import-and-directory-symlink-target-agree-but-do-not-match-disk.js +++ b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-import-and-directory-symlink-target-agree-but-do-not-match-disk.js @@ -45,7 +45,7 @@ Output::    ~~~~~~~~ ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' Xy/a.ts Imported via "./Xy/a" from file 'b.ts' Matched by include pattern '**/*' in 'tsconfig.json' @@ -163,7 +163,7 @@ Output::    ~~~~~~~~ ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' Xy/a.ts Imported via "./Xy/a" from file 'b.ts' Matched by include pattern '**/*' in 'tsconfig.json' diff --git a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-import-and-file-symlink-target-agree-but-do-not-match-disk.js b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-import-and-file-symlink-target-agree-but-do-not-match-disk.js index 3f0f145845065..f0059e68a8b7b 100644 --- a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-import-and-file-symlink-target-agree-but-do-not-match-disk.js +++ b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-import-and-file-symlink-target-agree-but-do-not-match-disk.js @@ -45,7 +45,7 @@ Output::    ~~~~~~ ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' XY.ts Matched by include pattern '**/*' in 'tsconfig.json' Imported via "./Xy" from file 'b.ts' @@ -151,7 +151,7 @@ Output::    ~~~~~~ ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' XY.ts Matched by include pattern '**/*' in 'tsconfig.json' Imported via "./Xy" from file 'b.ts' diff --git a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-import-matches-disk-but-directory-symlink-target-does-not.js b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-import-matches-disk-but-directory-symlink-target-does-not.js index d54b3f06b2648..effb28f973961 100644 --- a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-import-matches-disk-but-directory-symlink-target-does-not.js +++ b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-import-matches-disk-but-directory-symlink-target-does-not.js @@ -45,7 +45,7 @@ Output::    ~~~~~~~~ ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' Xy/a.ts Imported via "./Xy/a" from file 'b.ts' Matched by include pattern '**/*' in 'tsconfig.json' @@ -163,7 +163,7 @@ Output::    ~~~~~~~~ ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' Xy/a.ts Imported via "./Xy/a" from file 'b.ts' Matched by include pattern '**/*' in 'tsconfig.json' diff --git a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-import-matches-disk-but-file-symlink-target-does-not.js b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-import-matches-disk-but-file-symlink-target-does-not.js index c62772d275d25..23c67c71ac06b 100644 --- a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-import-matches-disk-but-file-symlink-target-does-not.js +++ b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-import-matches-disk-but-file-symlink-target-does-not.js @@ -45,7 +45,7 @@ Output::    ~~~~~~ ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' XY.ts Matched by include pattern '**/*' in 'tsconfig.json' Imported via "./Xy" from file 'b.ts' @@ -151,7 +151,7 @@ Output::    ~~~~~~ ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' XY.ts Matched by include pattern '**/*' in 'tsconfig.json' Imported via "./Xy" from file 'b.ts' diff --git a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-relative-information-file-location-changes.js b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-relative-information-file-location-changes.js index 0eff5f906f7d1..481cc141c2a56 100644 --- a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-relative-information-file-location-changes.js +++ b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/when-relative-information-file-location-changes.js @@ -59,7 +59,7 @@ Output:: File is included via import here. ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ModuleC.ts Imported via "./ModuleC" from file 'moduleA.ts' Imported via "./moduleC" from file 'moduleB.ts' @@ -174,7 +174,7 @@ Output:: File is included via import here. ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ModuleC.ts Imported via "./ModuleC" from file 'moduleA.ts' Imported via "./moduleC" from file 'moduleB.ts' diff --git a/tests/baselines/reference/tscWatch/incremental/jsxImportSource-option-changed-incremental.js b/tests/baselines/reference/tscWatch/incremental/jsxImportSource-option-changed-incremental.js index 38630e619acfd..ad6442b726541 100644 --- a/tests/baselines/reference/tscWatch/incremental/jsxImportSource-option-changed-incremental.js +++ b/tests/baselines/reference/tscWatch/incremental/jsxImportSource-option-changed-incremental.js @@ -58,7 +58,7 @@ export const App = () =>
; /a/lib/tsc.js -i --explainFiles Output:: ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' node_modules/react/jsx-runtime/index.d.ts Imported via "react/jsx-runtime" from file 'index.tsx' with packageId 'react/jsx-runtime/index.d.ts@0.0.1' to import 'jsx' and 'jsxs' factory functions index.tsx @@ -172,7 +172,7 @@ Output::    ~~~~~ ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' node_modules/preact/jsx-runtime/index.d.ts Imported via "preact/jsx-runtime" from file 'index.tsx' with packageId 'preact/jsx-runtime/index.d.ts@0.0.1' to import 'jsx' and 'jsxs' factory functions index.tsx diff --git a/tests/baselines/reference/tscWatch/incremental/jsxImportSource-option-changed-watch.js b/tests/baselines/reference/tscWatch/incremental/jsxImportSource-option-changed-watch.js index c18f3be8f52bb..a015c1fffc23c 100644 --- a/tests/baselines/reference/tscWatch/incremental/jsxImportSource-option-changed-watch.js +++ b/tests/baselines/reference/tscWatch/incremental/jsxImportSource-option-changed-watch.js @@ -61,7 +61,7 @@ Output:: [12:00:39 AM] Starting compilation in watch mode... ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' node_modules/react/jsx-runtime/index.d.ts Imported via "react/jsx-runtime" from file 'index.tsx' with packageId 'react/jsx-runtime/index.d.ts@0.0.1' to import 'jsx' and 'jsxs' factory functions index.tsx @@ -194,7 +194,7 @@ Output::    ~~~~~ ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' node_modules/preact/jsx-runtime/index.d.ts Imported via "preact/jsx-runtime" from file 'index.tsx' with packageId 'preact/jsx-runtime/index.d.ts@0.0.1' to import 'jsx' and 'jsxs' factory functions index.tsx diff --git a/tests/baselines/reference/tscWatch/programUpdates/changes-in-files-are-reflected-in-project-structure.js b/tests/baselines/reference/tscWatch/programUpdates/changes-in-files-are-reflected-in-project-structure.js index 4f21e9cf90663..304bbecca58b1 100644 --- a/tests/baselines/reference/tscWatch/programUpdates/changes-in-files-are-reflected-in-project-structure.js +++ b/tests/baselines/reference/tscWatch/programUpdates/changes-in-files-are-reflected-in-project-structure.js @@ -28,7 +28,7 @@ Output:: [12:00:19 AM] Starting compilation in watch mode... a/lib/lib.d.ts - Default library + Default library for target 'es3' a/b/f2.ts Imported via "./f2" from file 'a/b/f1.ts' a/b/f1.ts @@ -105,7 +105,7 @@ Output:: [12:00:27 AM] File change detected. Starting incremental compilation... a/lib/lib.d.ts - Default library + Default library for target 'es3' a/c/f3.ts Imported via "../c/f3" from file 'a/b/f2.ts' a/b/f2.ts diff --git a/tests/baselines/reference/tscWatch/programUpdates/handle-recreated-files-correctly.js b/tests/baselines/reference/tscWatch/programUpdates/handle-recreated-files-correctly.js index a8912e59ee4af..a1adb29d11034 100644 --- a/tests/baselines/reference/tscWatch/programUpdates/handle-recreated-files-correctly.js +++ b/tests/baselines/reference/tscWatch/programUpdates/handle-recreated-files-correctly.js @@ -28,7 +28,7 @@ Output:: [12:00:17 AM] Starting compilation in watch mode... a/lib/lib.d.ts - Default library + Default library for target 'es3' a/b/commonFile1.ts Matched by include pattern '**/*' in 'a/b/tsconfig.json' a/b/commonFile2.ts @@ -96,7 +96,7 @@ Output:: [12:00:25 AM] File change detected. Starting incremental compilation... a/lib/lib.d.ts - Default library + Default library for target 'es3' a/b/commonFile1.ts Matched by include pattern '**/*' in 'a/b/tsconfig.json' a/b/commonFile2.ts @@ -159,7 +159,7 @@ Output:: [12:00:34 AM] File change detected. Starting incremental compilation... a/lib/lib.d.ts - Default library + Default library for target 'es3' a/b/commonFile1.ts Matched by include pattern '**/*' in 'a/b/tsconfig.json' [12:00:38 AM] Found 0 errors. Watching for file changes. @@ -211,7 +211,7 @@ Output:: [12:00:41 AM] File change detected. Starting incremental compilation... a/lib/lib.d.ts - Default library + Default library for target 'es3' a/b/commonFile1.ts Matched by include pattern '**/*' in 'a/b/tsconfig.json' a/b/commonFile2.ts diff --git a/tests/baselines/reference/tscWatch/programUpdates/should-reflect-change-in-config-file.js b/tests/baselines/reference/tscWatch/programUpdates/should-reflect-change-in-config-file.js index 9c2504a22196e..f645329658ee8 100644 --- a/tests/baselines/reference/tscWatch/programUpdates/should-reflect-change-in-config-file.js +++ b/tests/baselines/reference/tscWatch/programUpdates/should-reflect-change-in-config-file.js @@ -31,7 +31,7 @@ Output:: [12:00:17 AM] Starting compilation in watch mode... a/lib/lib.d.ts - Default library + Default library for target 'es3' a/b/commonFile1.ts Part of 'files' list in tsconfig.json a/b/commonFile2.ts @@ -97,7 +97,7 @@ Output:: [12:00:25 AM] File change detected. Starting incremental compilation... a/lib/lib.d.ts - Default library + Default library for target 'es3' a/b/commonFile1.ts Part of 'files' list in tsconfig.json a/b/commonFile2.ts @@ -163,7 +163,7 @@ Output:: [12:00:36 AM] File change detected. Starting incremental compilation... a/lib/lib.d.ts - Default library + Default library for target 'es3' a/b/commonFile1.ts Part of 'files' list in tsconfig.json [12:00:40 AM] Found 0 errors. Watching for file changes. diff --git a/tests/baselines/reference/tsserver/configuredProjects/creating-new-file-and-then-open-it-after-watcher-is-invoked,-ask-errors-on-it-after-old-one-without-file-being-in-config.js b/tests/baselines/reference/tsserver/configuredProjects/creating-new-file-and-then-open-it-after-watcher-is-invoked,-ask-errors-on-it-after-old-one-without-file-being-in-config.js index 325bc051f381f..96d0a07984ea5 100644 --- a/tests/baselines/reference/tsserver/configuredProjects/creating-new-file-and-then-open-it-after-watcher-is-invoked,-ask-errors-on-it-after-old-one-without-file-being-in-config.js +++ b/tests/baselines/reference/tsserver/configuredProjects/creating-new-file-and-then-open-it-after-watcher-is-invoked,-ask-errors-on-it-after-old-one-without-file-being-in-config.js @@ -32,7 +32,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/bar.ts Matched by include pattern './src' in 'tsconfig.json' src/foo.ts diff --git a/tests/baselines/reference/tsserver/configuredProjects/creating-new-file-and-then-open-it-after-watcher-is-invoked,-ask-errors-on-it-after-old-one.js b/tests/baselines/reference/tsserver/configuredProjects/creating-new-file-and-then-open-it-after-watcher-is-invoked,-ask-errors-on-it-after-old-one.js index 337fd59507a6d..dfb62bb307403 100644 --- a/tests/baselines/reference/tsserver/configuredProjects/creating-new-file-and-then-open-it-after-watcher-is-invoked,-ask-errors-on-it-after-old-one.js +++ b/tests/baselines/reference/tsserver/configuredProjects/creating-new-file-and-then-open-it-after-watcher-is-invoked,-ask-errors-on-it-after-old-one.js @@ -32,7 +32,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/bar.ts Matched by include pattern './src' in 'tsconfig.json' src/foo.ts @@ -71,7 +71,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/bar.ts Matched by include pattern './src' in 'tsconfig.json' src/foo.ts diff --git a/tests/baselines/reference/tsserver/configuredProjects/creating-new-file-and-then-open-it-after-watcher-is-invoked,-ask-errors-on-it-before-old-one-without-file-being-in-config.js b/tests/baselines/reference/tsserver/configuredProjects/creating-new-file-and-then-open-it-after-watcher-is-invoked,-ask-errors-on-it-before-old-one-without-file-being-in-config.js index 7702cbca6d98b..8084ad64c472d 100644 --- a/tests/baselines/reference/tsserver/configuredProjects/creating-new-file-and-then-open-it-after-watcher-is-invoked,-ask-errors-on-it-before-old-one-without-file-being-in-config.js +++ b/tests/baselines/reference/tsserver/configuredProjects/creating-new-file-and-then-open-it-after-watcher-is-invoked,-ask-errors-on-it-before-old-one-without-file-being-in-config.js @@ -32,7 +32,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/bar.ts Matched by include pattern './src' in 'tsconfig.json' src/foo.ts diff --git a/tests/baselines/reference/tsserver/configuredProjects/creating-new-file-and-then-open-it-after-watcher-is-invoked,-ask-errors-on-it-before-old-one.js b/tests/baselines/reference/tsserver/configuredProjects/creating-new-file-and-then-open-it-after-watcher-is-invoked,-ask-errors-on-it-before-old-one.js index 6bf78ae82a4c5..e5da699f3861a 100644 --- a/tests/baselines/reference/tsserver/configuredProjects/creating-new-file-and-then-open-it-after-watcher-is-invoked,-ask-errors-on-it-before-old-one.js +++ b/tests/baselines/reference/tsserver/configuredProjects/creating-new-file-and-then-open-it-after-watcher-is-invoked,-ask-errors-on-it-before-old-one.js @@ -32,7 +32,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/bar.ts Matched by include pattern './src' in 'tsconfig.json' src/foo.ts @@ -71,7 +71,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/bar.ts Matched by include pattern './src' in 'tsconfig.json' src/foo.ts diff --git a/tests/baselines/reference/tsserver/configuredProjects/creating-new-file-and-then-open-it-before-watcher-is-invoked,-ask-errors-on-it-after-old-one-without-file-being-in-config.js b/tests/baselines/reference/tsserver/configuredProjects/creating-new-file-and-then-open-it-before-watcher-is-invoked,-ask-errors-on-it-after-old-one-without-file-being-in-config.js index 1c39c0c715d34..4336a83c99f93 100644 --- a/tests/baselines/reference/tsserver/configuredProjects/creating-new-file-and-then-open-it-before-watcher-is-invoked,-ask-errors-on-it-after-old-one-without-file-being-in-config.js +++ b/tests/baselines/reference/tsserver/configuredProjects/creating-new-file-and-then-open-it-before-watcher-is-invoked,-ask-errors-on-it-after-old-one-without-file-being-in-config.js @@ -32,7 +32,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/bar.ts Matched by include pattern './src' in 'tsconfig.json' src/foo.ts diff --git a/tests/baselines/reference/tsserver/configuredProjects/creating-new-file-and-then-open-it-before-watcher-is-invoked,-ask-errors-on-it-after-old-one.js b/tests/baselines/reference/tsserver/configuredProjects/creating-new-file-and-then-open-it-before-watcher-is-invoked,-ask-errors-on-it-after-old-one.js index c829851b74ff9..6a0eac03a9f58 100644 --- a/tests/baselines/reference/tsserver/configuredProjects/creating-new-file-and-then-open-it-before-watcher-is-invoked,-ask-errors-on-it-after-old-one.js +++ b/tests/baselines/reference/tsserver/configuredProjects/creating-new-file-and-then-open-it-before-watcher-is-invoked,-ask-errors-on-it-after-old-one.js @@ -32,7 +32,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/bar.ts Matched by include pattern './src' in 'tsconfig.json' src/foo.ts @@ -120,7 +120,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/bar.ts Matched by include pattern './src' in 'tsconfig.json' src/foo.ts diff --git a/tests/baselines/reference/tsserver/configuredProjects/creating-new-file-and-then-open-it-before-watcher-is-invoked,-ask-errors-on-it-before-old-one-without-file-being-in-config.js b/tests/baselines/reference/tsserver/configuredProjects/creating-new-file-and-then-open-it-before-watcher-is-invoked,-ask-errors-on-it-before-old-one-without-file-being-in-config.js index 7f69e67354d27..f96320da3a712 100644 --- a/tests/baselines/reference/tsserver/configuredProjects/creating-new-file-and-then-open-it-before-watcher-is-invoked,-ask-errors-on-it-before-old-one-without-file-being-in-config.js +++ b/tests/baselines/reference/tsserver/configuredProjects/creating-new-file-and-then-open-it-before-watcher-is-invoked,-ask-errors-on-it-before-old-one-without-file-being-in-config.js @@ -32,7 +32,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/bar.ts Matched by include pattern './src' in 'tsconfig.json' src/foo.ts diff --git a/tests/baselines/reference/tsserver/configuredProjects/creating-new-file-and-then-open-it-before-watcher-is-invoked,-ask-errors-on-it-before-old-one.js b/tests/baselines/reference/tsserver/configuredProjects/creating-new-file-and-then-open-it-before-watcher-is-invoked,-ask-errors-on-it-before-old-one.js index a667534acafff..62214db3c51e3 100644 --- a/tests/baselines/reference/tsserver/configuredProjects/creating-new-file-and-then-open-it-before-watcher-is-invoked,-ask-errors-on-it-before-old-one.js +++ b/tests/baselines/reference/tsserver/configuredProjects/creating-new-file-and-then-open-it-before-watcher-is-invoked,-ask-errors-on-it-before-old-one.js @@ -32,7 +32,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/bar.ts Matched by include pattern './src' in 'tsconfig.json' src/foo.ts @@ -126,7 +126,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/bar.ts Matched by include pattern './src' in 'tsconfig.json' src/foo.ts diff --git a/tests/baselines/reference/tsserver/forceConsistentCasingInFileNames/when-changing-module-name-with-different-casing.js b/tests/baselines/reference/tsserver/forceConsistentCasingInFileNames/when-changing-module-name-with-different-casing.js index f01516e4e14e8..4b5747816f6be 100644 --- a/tests/baselines/reference/tsserver/forceConsistentCasingInFileNames/when-changing-module-name-with-different-casing.js +++ b/tests/baselines/reference/tsserver/forceConsistentCasingInFileNames/when-changing-module-name-with-different-casing.js @@ -33,7 +33,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' Logger.ts Matched by include pattern '**/*' in 'tsconfig.json' Imported via "./Logger" from file 'another.ts' diff --git a/tests/baselines/reference/tsserver/forceConsistentCasingInFileNames/works-when-renaming-file-with-different-casing.js b/tests/baselines/reference/tsserver/forceConsistentCasingInFileNames/works-when-renaming-file-with-different-casing.js index ed681eaf86b15..1af314f8ae86a 100644 --- a/tests/baselines/reference/tsserver/forceConsistentCasingInFileNames/works-when-renaming-file-with-different-casing.js +++ b/tests/baselines/reference/tsserver/forceConsistentCasingInFileNames/works-when-renaming-file-with-different-casing.js @@ -33,7 +33,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' Logger.ts Matched by include pattern '**/*' in 'tsconfig.json' Imported via "./Logger" from file 'another.ts' diff --git a/tests/baselines/reference/tsserver/projectErrors/configFileDiagnostic-events-are-generated-when-the-config-file-changes.js b/tests/baselines/reference/tsserver/projectErrors/configFileDiagnostic-events-are-generated-when-the-config-file-changes.js index 8c242cf0fecd9..c290bb78497b0 100644 --- a/tests/baselines/reference/tsserver/projectErrors/configFileDiagnostic-events-are-generated-when-the-config-file-changes.js +++ b/tests/baselines/reference/tsserver/projectErrors/configFileDiagnostic-events-are-generated-when-the-config-file-changes.js @@ -29,7 +29,7 @@ Project '/a/b/tsconfig.json' (Configured) ../lib/lib.d.ts - Default library + Default library for target 'es3' app.ts Matched by include pattern '**/*' in 'tsconfig.json' diff --git a/tests/baselines/reference/tsserver/projectErrors/configFileDiagnostic-events-are-generated-when-the-config-file-doesnt-have-errors.js b/tests/baselines/reference/tsserver/projectErrors/configFileDiagnostic-events-are-generated-when-the-config-file-doesnt-have-errors.js index 9688e4a49068f..99c6e880c5c2c 100644 --- a/tests/baselines/reference/tsserver/projectErrors/configFileDiagnostic-events-are-generated-when-the-config-file-doesnt-have-errors.js +++ b/tests/baselines/reference/tsserver/projectErrors/configFileDiagnostic-events-are-generated-when-the-config-file-doesnt-have-errors.js @@ -29,7 +29,7 @@ Project '/a/b/tsconfig.json' (Configured) ../lib/lib.d.ts - Default library + Default library for target 'es3' app.ts Matched by include pattern '**/*' in 'tsconfig.json' diff --git a/tests/baselines/reference/tsserver/projectErrors/configFileDiagnostic-events-are-generated-when-the-config-file-has-errors.js b/tests/baselines/reference/tsserver/projectErrors/configFileDiagnostic-events-are-generated-when-the-config-file-has-errors.js index 032b65c6a58a9..127e18a12073d 100644 --- a/tests/baselines/reference/tsserver/projectErrors/configFileDiagnostic-events-are-generated-when-the-config-file-has-errors.js +++ b/tests/baselines/reference/tsserver/projectErrors/configFileDiagnostic-events-are-generated-when-the-config-file-has-errors.js @@ -29,7 +29,7 @@ Project '/a/b/tsconfig.json' (Configured) ../lib/lib.d.ts - Default library + Default library for target 'es3' app.ts Matched by include pattern '**/*' in 'tsconfig.json' diff --git a/tests/baselines/reference/tsserver/projectErrors/configFileDiagnostic-events-are-not-generated-when-the-config-file-does-not-include-file-opened-and-config-file-has-errors.js b/tests/baselines/reference/tsserver/projectErrors/configFileDiagnostic-events-are-not-generated-when-the-config-file-does-not-include-file-opened-and-config-file-has-errors.js index b0684a5698ddc..f882b6b064d5a 100644 --- a/tests/baselines/reference/tsserver/projectErrors/configFileDiagnostic-events-are-not-generated-when-the-config-file-does-not-include-file-opened-and-config-file-has-errors.js +++ b/tests/baselines/reference/tsserver/projectErrors/configFileDiagnostic-events-are-not-generated-when-the-config-file-does-not-include-file-opened-and-config-file-has-errors.js @@ -28,7 +28,7 @@ Project '/a/b/tsconfig.json' (Configured) ../lib/lib.d.ts - Default library + Default library for target 'es3' app.ts Part of 'files' list in tsconfig.json diff --git a/tests/baselines/reference/tsserver/projectErrors/configFileDiagnostic-events-are-not-generated-when-the-config-file-does-not-include-file-opened-and-doesnt-contain-any-errors.js b/tests/baselines/reference/tsserver/projectErrors/configFileDiagnostic-events-are-not-generated-when-the-config-file-does-not-include-file-opened-and-doesnt-contain-any-errors.js index 25d9ca79a925d..77afe57d1a0a2 100644 --- a/tests/baselines/reference/tsserver/projectErrors/configFileDiagnostic-events-are-not-generated-when-the-config-file-does-not-include-file-opened-and-doesnt-contain-any-errors.js +++ b/tests/baselines/reference/tsserver/projectErrors/configFileDiagnostic-events-are-not-generated-when-the-config-file-does-not-include-file-opened-and-doesnt-contain-any-errors.js @@ -28,7 +28,7 @@ Project '/a/b/tsconfig.json' (Configured) ../lib/lib.d.ts - Default library + Default library for target 'es3' app.ts Part of 'files' list in tsconfig.json diff --git a/tests/baselines/reference/tsserver/projectErrors/configFileDiagnostic-events-are-not-generated-when-the-config-file-has-errors-but-suppressDiagnosticEvents-is-true.js b/tests/baselines/reference/tsserver/projectErrors/configFileDiagnostic-events-are-not-generated-when-the-config-file-has-errors-but-suppressDiagnosticEvents-is-true.js index b729e90e9b23c..41cfb0ff06673 100644 --- a/tests/baselines/reference/tsserver/projectErrors/configFileDiagnostic-events-are-not-generated-when-the-config-file-has-errors-but-suppressDiagnosticEvents-is-true.js +++ b/tests/baselines/reference/tsserver/projectErrors/configFileDiagnostic-events-are-not-generated-when-the-config-file-has-errors-but-suppressDiagnosticEvents-is-true.js @@ -29,7 +29,7 @@ Project '/a/b/tsconfig.json' (Configured) ../lib/lib.d.ts - Default library + Default library for target 'es3' app.ts Matched by include pattern '**/*' in 'tsconfig.json' diff --git a/tests/baselines/reference/tsserver/projectErrors/configFileDiagnostic-events-contains-the-project-reference-errors.js b/tests/baselines/reference/tsserver/projectErrors/configFileDiagnostic-events-contains-the-project-reference-errors.js index 921b483df6b03..64727ed96257e 100644 --- a/tests/baselines/reference/tsserver/projectErrors/configFileDiagnostic-events-contains-the-project-reference-errors.js +++ b/tests/baselines/reference/tsserver/projectErrors/configFileDiagnostic-events-contains-the-project-reference-errors.js @@ -42,7 +42,7 @@ Project '/a/b/tsconfig.json' (Configured) ../lib/lib.d.ts - Default library + Default library for target 'es3' app.ts Part of 'files' list in tsconfig.json diff --git a/tests/baselines/reference/tsserver/projectErrors/correct-errors-when-resolution-resolves-to-file-that-has-same-ambient-module-and-is-also-module.js b/tests/baselines/reference/tsserver/projectErrors/correct-errors-when-resolution-resolves-to-file-that-has-same-ambient-module-and-is-also-module.js index 2bd9071b01162..a5b8f28ac9430 100644 --- a/tests/baselines/reference/tsserver/projectErrors/correct-errors-when-resolution-resolves-to-file-that-has-same-ambient-module-and-is-also-module.js +++ b/tests/baselines/reference/tsserver/projectErrors/correct-errors-when-resolution-resolves-to-file-that-has-same-ambient-module-and-is-also-module.js @@ -35,7 +35,7 @@ Project '/users/username/projects/myproject/tsconfig.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' node_modules/@custom/plugin/proposed.d.ts Imported via './proposed' from file 'node_modules/@custom/plugin/index.d.ts' node_modules/@custom/plugin/index.d.ts diff --git a/tests/baselines/reference/tsserver/projectErrors/folder-rename-updates-project-structure-and-reports-no-errors.js b/tests/baselines/reference/tsserver/projectErrors/folder-rename-updates-project-structure-and-reports-no-errors.js index b505843b86c3e..9d4011c2649fc 100644 --- a/tests/baselines/reference/tsserver/projectErrors/folder-rename-updates-project-structure-and-reports-no-errors.js +++ b/tests/baselines/reference/tsserver/projectErrors/folder-rename-updates-project-structure-and-reports-no-errors.js @@ -42,7 +42,7 @@ event: event: {"seq":0,"type":"event","event":"telemetry","body":{"telemetryEventName":"projectInfo","payload":{"projectId":"c56abb8c7c51bef5953613f05226da8e72cd9eafe09ab58ca2ccd81b65ba193a","fileStats":{"js":0,"jsSize":0,"jsx":0,"jsxSize":0,"ts":2,"tsSize":154,"tsx":0,"tsxSize":0,"dts":0,"dtsSize":0,"deferred":0,"deferredSize":0},"compilerOptions":{"module":"none"},"typeAcquisition":{"enable":false,"include":false,"exclude":false},"extends":false,"files":false,"include":false,"exclude":true,"compileOnSave":false,"configFileName":"tsconfig.json","projectType":"configured","languageServiceEnabled":true,"version":"FakeVersion"}}} event: - {"seq":0,"type":"event","event":"configFileDiag","body":{"triggerFile":"/a/b/projects/myproject/bar/app.ts","configFile":"/a/b/projects/myproject/tsconfig.json","diagnostics":[{"text":"File '/a/lib/lib.d.ts' not found.\n The file is in the program because:\n Default library","code":6053,"category":"error"},{"text":"Cannot find global type 'Array'.","code":2318,"category":"error"},{"text":"Cannot find global type 'Boolean'.","code":2318,"category":"error"},{"text":"Cannot find global type 'Function'.","code":2318,"category":"error"},{"text":"Cannot find global type 'IArguments'.","code":2318,"category":"error"},{"text":"Cannot find global type 'Number'.","code":2318,"category":"error"},{"text":"Cannot find global type 'Object'.","code":2318,"category":"error"},{"text":"Cannot find global type 'RegExp'.","code":2318,"category":"error"},{"text":"Cannot find global type 'String'.","code":2318,"category":"error"},{"start":{"line":1,"offset":37},"end":{"line":1,"offset":45},"text":"Unknown compiler option 'targer'. Did you mean 'target'?","code":5025,"category":"error","fileName":"/a/b/projects/myproject/tsconfig.json"}]}} + {"seq":0,"type":"event","event":"configFileDiag","body":{"triggerFile":"/a/b/projects/myproject/bar/app.ts","configFile":"/a/b/projects/myproject/tsconfig.json","diagnostics":[{"text":"File '/a/lib/lib.d.ts' not found.\n The file is in the program because:\n Default library for target 'es3'","code":6053,"category":"error"},{"text":"Cannot find global type 'Array'.","code":2318,"category":"error"},{"text":"Cannot find global type 'Boolean'.","code":2318,"category":"error"},{"text":"Cannot find global type 'Function'.","code":2318,"category":"error"},{"text":"Cannot find global type 'IArguments'.","code":2318,"category":"error"},{"text":"Cannot find global type 'Number'.","code":2318,"category":"error"},{"text":"Cannot find global type 'Object'.","code":2318,"category":"error"},{"text":"Cannot find global type 'RegExp'.","code":2318,"category":"error"},{"text":"Cannot find global type 'String'.","code":2318,"category":"error"},{"start":{"line":1,"offset":37},"end":{"line":1,"offset":45},"text":"Unknown compiler option 'targer'. Did you mean 'target'?","code":5025,"category":"error","fileName":"/a/b/projects/myproject/tsconfig.json"}]}} Project '/a/b/projects/myproject/tsconfig.json' (Configured) Files (2) diff --git a/tests/baselines/reference/tsserver/projectErrors/npm-install-when-timeout-occurs-after-installation.js b/tests/baselines/reference/tsserver/projectErrors/npm-install-when-timeout-occurs-after-installation.js index 419c68f410458..584478548a45f 100644 --- a/tests/baselines/reference/tsserver/projectErrors/npm-install-when-timeout-occurs-after-installation.js +++ b/tests/baselines/reference/tsserver/projectErrors/npm-install-when-timeout-occurs-after-installation.js @@ -33,7 +33,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/main.ts Matched by include pattern '**/*' in 'tsconfig.json' @@ -233,7 +233,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' node_modules/@angular/core/index.d.ts Imported via '@angular/core' from file 'src/main.ts' src/main.ts diff --git a/tests/baselines/reference/tsserver/projectErrors/npm-install-when-timeout-occurs-inbetween-installation.js b/tests/baselines/reference/tsserver/projectErrors/npm-install-when-timeout-occurs-inbetween-installation.js index b17e03d859139..9fb71d1254428 100644 --- a/tests/baselines/reference/tsserver/projectErrors/npm-install-when-timeout-occurs-inbetween-installation.js +++ b/tests/baselines/reference/tsserver/projectErrors/npm-install-when-timeout-occurs-inbetween-installation.js @@ -33,7 +33,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/main.ts Matched by include pattern '**/*' in 'tsconfig.json' @@ -256,7 +256,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' node_modules/@angular/core/index.d.ts Imported via '@angular/core' from file 'src/main.ts' src/main.ts diff --git a/tests/baselines/reference/tsserver/projectErrors/should-not-report-incorrect-error-when-json-is-root-file-found-by-tsconfig.js b/tests/baselines/reference/tsserver/projectErrors/should-not-report-incorrect-error-when-json-is-root-file-found-by-tsconfig.js index 789290aa830d7..0d1830af78290 100644 --- a/tests/baselines/reference/tsserver/projectErrors/should-not-report-incorrect-error-when-json-is-root-file-found-by-tsconfig.js +++ b/tests/baselines/reference/tsserver/projectErrors/should-not-report-incorrect-error-when-json-is-root-file-found-by-tsconfig.js @@ -36,7 +36,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/blabla.json Imported via "./blabla.json" from file 'src/test.ts' Matched by include pattern './src/*.json' in 'tsconfig.json' diff --git a/tests/baselines/reference/tsserver/projectErrors/should-report-error-when-json-is-not-root-file-found-by-tsconfig.js b/tests/baselines/reference/tsserver/projectErrors/should-report-error-when-json-is-not-root-file-found-by-tsconfig.js index 6d6136fac9911..3d897aa23e320 100644 --- a/tests/baselines/reference/tsserver/projectErrors/should-report-error-when-json-is-not-root-file-found-by-tsconfig.js +++ b/tests/baselines/reference/tsserver/projectErrors/should-report-error-when-json-is-not-root-file-found-by-tsconfig.js @@ -35,7 +35,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/blabla.json Imported via "./blabla.json" from file 'src/test.ts' src/test.ts diff --git a/tests/baselines/reference/tsserver/projectErrors/when-semantic-error-returns-includes-global-error-gerErr-with-sync-commands.js b/tests/baselines/reference/tsserver/projectErrors/when-semantic-error-returns-includes-global-error-gerErr-with-sync-commands.js index 7eae40f0de5cc..ac2b48eaed2a7 100644 --- a/tests/baselines/reference/tsserver/projectErrors/when-semantic-error-returns-includes-global-error-gerErr-with-sync-commands.js +++ b/tests/baselines/reference/tsserver/projectErrors/when-semantic-error-returns-includes-global-error-gerErr-with-sync-commands.js @@ -27,7 +27,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ui.ts Matched by include pattern '**/*' in 'tsconfig.json' diff --git a/tests/baselines/reference/tsserver/projectErrors/when-semantic-error-returns-includes-global-error-getErr.js b/tests/baselines/reference/tsserver/projectErrors/when-semantic-error-returns-includes-global-error-getErr.js index 78983bd3745bc..e7f57c4b839e2 100644 --- a/tests/baselines/reference/tsserver/projectErrors/when-semantic-error-returns-includes-global-error-getErr.js +++ b/tests/baselines/reference/tsserver/projectErrors/when-semantic-error-returns-includes-global-error-getErr.js @@ -29,7 +29,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ui.ts Matched by include pattern '**/*' in 'tsconfig.json' diff --git a/tests/baselines/reference/tsserver/projectErrors/when-semantic-error-returns-includes-global-error-geterrForProject.js b/tests/baselines/reference/tsserver/projectErrors/when-semantic-error-returns-includes-global-error-geterrForProject.js index 364821360fa61..ca2aec830655e 100644 --- a/tests/baselines/reference/tsserver/projectErrors/when-semantic-error-returns-includes-global-error-geterrForProject.js +++ b/tests/baselines/reference/tsserver/projectErrors/when-semantic-error-returns-includes-global-error-geterrForProject.js @@ -29,7 +29,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ui.ts Matched by include pattern '**/*' in 'tsconfig.json' diff --git a/tests/baselines/reference/tsserver/projectLanguageServiceStateEvent/large-file-size-is-determined-correctly.js b/tests/baselines/reference/tsserver/projectLanguageServiceStateEvent/large-file-size-is-determined-correctly.js index 8d1455b514238..98221e5c651b8 100644 --- a/tests/baselines/reference/tsserver/projectLanguageServiceStateEvent/large-file-size-is-determined-correctly.js +++ b/tests/baselines/reference/tsserver/projectLanguageServiceStateEvent/large-file-size-is-determined-correctly.js @@ -33,7 +33,7 @@ Project '/a/jsconfig.json' (Configured) lib/lib.d.ts - Default library + Default library for target 'es3' app.js Matched by include pattern '**/*' in 'jsconfig.json' diff --git a/tests/baselines/reference/tsserver/projectReferenceErrors/with-module-scenario-when-dependency-project-is-not-open-gerErr-with-sync-commands.js b/tests/baselines/reference/tsserver/projectReferenceErrors/with-module-scenario-when-dependency-project-is-not-open-gerErr-with-sync-commands.js index 45c47d45b079e..c4626262b1f57 100644 --- a/tests/baselines/reference/tsserver/projectReferenceErrors/with-module-scenario-when-dependency-project-is-not-open-gerErr-with-sync-commands.js +++ b/tests/baselines/reference/tsserver/projectReferenceErrors/with-module-scenario-when-dependency-project-is-not-open-gerErr-with-sync-commands.js @@ -53,7 +53,7 @@ Project '/user/username/projects/myproject/usage/tsconfig.json' (Configured) ../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../dependency/fns.ts Imported via '../decls/fns' from file 'usage.ts' usage.ts diff --git a/tests/baselines/reference/tsserver/projectReferenceErrors/with-module-scenario-when-dependency-project-is-not-open-getErr.js b/tests/baselines/reference/tsserver/projectReferenceErrors/with-module-scenario-when-dependency-project-is-not-open-getErr.js index 561c60b7d7d08..5ec2fe654cf39 100644 --- a/tests/baselines/reference/tsserver/projectReferenceErrors/with-module-scenario-when-dependency-project-is-not-open-getErr.js +++ b/tests/baselines/reference/tsserver/projectReferenceErrors/with-module-scenario-when-dependency-project-is-not-open-getErr.js @@ -55,7 +55,7 @@ Project '/user/username/projects/myproject/usage/tsconfig.json' (Configured) ../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../dependency/fns.ts Imported via '../decls/fns' from file 'usage.ts' usage.ts diff --git a/tests/baselines/reference/tsserver/projectReferenceErrors/with-module-scenario-when-dependency-project-is-not-open-geterrForProject.js b/tests/baselines/reference/tsserver/projectReferenceErrors/with-module-scenario-when-dependency-project-is-not-open-geterrForProject.js index ec714b9f6dfef..9aac5c5526945 100644 --- a/tests/baselines/reference/tsserver/projectReferenceErrors/with-module-scenario-when-dependency-project-is-not-open-geterrForProject.js +++ b/tests/baselines/reference/tsserver/projectReferenceErrors/with-module-scenario-when-dependency-project-is-not-open-geterrForProject.js @@ -55,7 +55,7 @@ Project '/user/username/projects/myproject/usage/tsconfig.json' (Configured) ../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../dependency/fns.ts Imported via '../decls/fns' from file 'usage.ts' usage.ts diff --git a/tests/baselines/reference/tsserver/projectReferenceErrors/with-module-scenario-when-the-depedency-file-is-open-gerErr-with-sync-commands.js b/tests/baselines/reference/tsserver/projectReferenceErrors/with-module-scenario-when-the-depedency-file-is-open-gerErr-with-sync-commands.js index da8fb9a79ca01..615d011501120 100644 --- a/tests/baselines/reference/tsserver/projectReferenceErrors/with-module-scenario-when-the-depedency-file-is-open-gerErr-with-sync-commands.js +++ b/tests/baselines/reference/tsserver/projectReferenceErrors/with-module-scenario-when-the-depedency-file-is-open-gerErr-with-sync-commands.js @@ -53,7 +53,7 @@ Project '/user/username/projects/myproject/usage/tsconfig.json' (Configured) ../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../dependency/fns.ts Imported via '../decls/fns' from file 'usage.ts' usage.ts @@ -89,7 +89,7 @@ Project '/user/username/projects/myproject/dependency/tsconfig.json' (Configured ../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' fns.ts Matched by include pattern '**/*' in 'tsconfig.json' diff --git a/tests/baselines/reference/tsserver/projectReferenceErrors/with-module-scenario-when-the-depedency-file-is-open-getErr.js b/tests/baselines/reference/tsserver/projectReferenceErrors/with-module-scenario-when-the-depedency-file-is-open-getErr.js index a650ce4c29fe1..1c9a4d1781926 100644 --- a/tests/baselines/reference/tsserver/projectReferenceErrors/with-module-scenario-when-the-depedency-file-is-open-getErr.js +++ b/tests/baselines/reference/tsserver/projectReferenceErrors/with-module-scenario-when-the-depedency-file-is-open-getErr.js @@ -55,7 +55,7 @@ Project '/user/username/projects/myproject/usage/tsconfig.json' (Configured) ../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../dependency/fns.ts Imported via '../decls/fns' from file 'usage.ts' usage.ts @@ -99,7 +99,7 @@ Project '/user/username/projects/myproject/dependency/tsconfig.json' (Configured ../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' fns.ts Matched by include pattern '**/*' in 'tsconfig.json' diff --git a/tests/baselines/reference/tsserver/projectReferenceErrors/with-module-scenario-when-the-depedency-file-is-open-geterrForProject.js b/tests/baselines/reference/tsserver/projectReferenceErrors/with-module-scenario-when-the-depedency-file-is-open-geterrForProject.js index 684abf3f76755..18e76ddb5e077 100644 --- a/tests/baselines/reference/tsserver/projectReferenceErrors/with-module-scenario-when-the-depedency-file-is-open-geterrForProject.js +++ b/tests/baselines/reference/tsserver/projectReferenceErrors/with-module-scenario-when-the-depedency-file-is-open-geterrForProject.js @@ -55,7 +55,7 @@ Project '/user/username/projects/myproject/usage/tsconfig.json' (Configured) ../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../dependency/fns.ts Imported via '../decls/fns' from file 'usage.ts' usage.ts @@ -99,7 +99,7 @@ Project '/user/username/projects/myproject/dependency/tsconfig.json' (Configured ../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' fns.ts Matched by include pattern '**/*' in 'tsconfig.json' diff --git a/tests/baselines/reference/tsserver/projectReferenceErrors/with-non-module-when-dependency-project-is-not-open-gerErr-with-sync-commands.js b/tests/baselines/reference/tsserver/projectReferenceErrors/with-non-module-when-dependency-project-is-not-open-gerErr-with-sync-commands.js index a0f7645600aa5..d54d8a8ed4c58 100644 --- a/tests/baselines/reference/tsserver/projectReferenceErrors/with-non-module-when-dependency-project-is-not-open-gerErr-with-sync-commands.js +++ b/tests/baselines/reference/tsserver/projectReferenceErrors/with-non-module-when-dependency-project-is-not-open-gerErr-with-sync-commands.js @@ -52,7 +52,7 @@ Project '/user/username/projects/myproject/usage/tsconfig.json' (Configured) ../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../dependency/fns.ts Source from referenced project '../dependency/tsconfig.json' included because '--outFile' specified usage.ts diff --git a/tests/baselines/reference/tsserver/projectReferenceErrors/with-non-module-when-dependency-project-is-not-open-getErr.js b/tests/baselines/reference/tsserver/projectReferenceErrors/with-non-module-when-dependency-project-is-not-open-getErr.js index 8df29aefc933e..cd4980e3517a8 100644 --- a/tests/baselines/reference/tsserver/projectReferenceErrors/with-non-module-when-dependency-project-is-not-open-getErr.js +++ b/tests/baselines/reference/tsserver/projectReferenceErrors/with-non-module-when-dependency-project-is-not-open-getErr.js @@ -54,7 +54,7 @@ Project '/user/username/projects/myproject/usage/tsconfig.json' (Configured) ../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../dependency/fns.ts Source from referenced project '../dependency/tsconfig.json' included because '--outFile' specified usage.ts diff --git a/tests/baselines/reference/tsserver/projectReferenceErrors/with-non-module-when-dependency-project-is-not-open-geterrForProject.js b/tests/baselines/reference/tsserver/projectReferenceErrors/with-non-module-when-dependency-project-is-not-open-geterrForProject.js index 5324f46408194..0441470c96582 100644 --- a/tests/baselines/reference/tsserver/projectReferenceErrors/with-non-module-when-dependency-project-is-not-open-geterrForProject.js +++ b/tests/baselines/reference/tsserver/projectReferenceErrors/with-non-module-when-dependency-project-is-not-open-geterrForProject.js @@ -54,7 +54,7 @@ Project '/user/username/projects/myproject/usage/tsconfig.json' (Configured) ../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../dependency/fns.ts Source from referenced project '../dependency/tsconfig.json' included because '--outFile' specified usage.ts diff --git a/tests/baselines/reference/tsserver/projectReferenceErrors/with-non-module-when-the-depedency-file-is-open-gerErr-with-sync-commands.js b/tests/baselines/reference/tsserver/projectReferenceErrors/with-non-module-when-the-depedency-file-is-open-gerErr-with-sync-commands.js index 46987608856db..07b7d01685ea4 100644 --- a/tests/baselines/reference/tsserver/projectReferenceErrors/with-non-module-when-the-depedency-file-is-open-gerErr-with-sync-commands.js +++ b/tests/baselines/reference/tsserver/projectReferenceErrors/with-non-module-when-the-depedency-file-is-open-gerErr-with-sync-commands.js @@ -52,7 +52,7 @@ Project '/user/username/projects/myproject/usage/tsconfig.json' (Configured) ../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../dependency/fns.ts Source from referenced project '../dependency/tsconfig.json' included because '--outFile' specified usage.ts @@ -88,7 +88,7 @@ Project '/user/username/projects/myproject/dependency/tsconfig.json' (Configured ../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' fns.ts Matched by include pattern '**/*' in 'tsconfig.json' diff --git a/tests/baselines/reference/tsserver/projectReferenceErrors/with-non-module-when-the-depedency-file-is-open-getErr.js b/tests/baselines/reference/tsserver/projectReferenceErrors/with-non-module-when-the-depedency-file-is-open-getErr.js index 38a5700630c27..bfd0a68ad057d 100644 --- a/tests/baselines/reference/tsserver/projectReferenceErrors/with-non-module-when-the-depedency-file-is-open-getErr.js +++ b/tests/baselines/reference/tsserver/projectReferenceErrors/with-non-module-when-the-depedency-file-is-open-getErr.js @@ -54,7 +54,7 @@ Project '/user/username/projects/myproject/usage/tsconfig.json' (Configured) ../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../dependency/fns.ts Source from referenced project '../dependency/tsconfig.json' included because '--outFile' specified usage.ts @@ -98,7 +98,7 @@ Project '/user/username/projects/myproject/dependency/tsconfig.json' (Configured ../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' fns.ts Matched by include pattern '**/*' in 'tsconfig.json' diff --git a/tests/baselines/reference/tsserver/projectReferenceErrors/with-non-module-when-the-depedency-file-is-open-geterrForProject.js b/tests/baselines/reference/tsserver/projectReferenceErrors/with-non-module-when-the-depedency-file-is-open-geterrForProject.js index 24c278e2f9905..d9f23968cc7c8 100644 --- a/tests/baselines/reference/tsserver/projectReferenceErrors/with-non-module-when-the-depedency-file-is-open-geterrForProject.js +++ b/tests/baselines/reference/tsserver/projectReferenceErrors/with-non-module-when-the-depedency-file-is-open-geterrForProject.js @@ -54,7 +54,7 @@ Project '/user/username/projects/myproject/usage/tsconfig.json' (Configured) ../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../dependency/fns.ts Source from referenced project '../dependency/tsconfig.json' included because '--outFile' specified usage.ts @@ -98,7 +98,7 @@ Project '/user/username/projects/myproject/dependency/tsconfig.json' (Configured ../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' fns.ts Matched by include pattern '**/*' in 'tsconfig.json' diff --git a/tests/baselines/reference/tsserver/projectReferences/ancestor-and-project-ref-management.js b/tests/baselines/reference/tsserver/projectReferences/ancestor-and-project-ref-management.js index c3b9c6f8d0df5..79bc5aad59d86 100644 --- a/tests/baselines/reference/tsserver/projectReferences/ancestor-and-project-ref-management.js +++ b/tests/baselines/reference/tsserver/projectReferences/ancestor-and-project-ref-management.js @@ -51,7 +51,7 @@ Project '/user/username/projects/container/compositeExec/tsconfig.json' (Configu ../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../lib/index.ts Source from referenced project '../lib/tsconfig.json' included because '--outFile' specified index.ts @@ -134,7 +134,7 @@ Project '/user/username/projects/container/lib/tsconfig.json' (Configured) ../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' index.ts Part of 'files' list in tsconfig.json @@ -196,7 +196,7 @@ Project '/user/username/projects/container/exec/tsconfig.json' (Configured) ../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../lib/index.ts Source from referenced project '../lib/tsconfig.json' included because '--outFile' specified index.ts @@ -353,7 +353,7 @@ Project '/user/username/projects/container/compositeExec/tsconfig.json' (Configu ../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../lib/index.ts Source from referenced project '../lib/tsconfig.json' included because '--outFile' specified index.ts @@ -383,7 +383,7 @@ Project '/user/username/projects/container/lib/tsconfig.json' (Configured) ../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' index.ts Part of 'files' list in tsconfig.json @@ -401,7 +401,7 @@ Project '/user/username/projects/container/exec/tsconfig.json' (Configured) ../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../lib/index.ts Source from referenced project '../lib/tsconfig.json' included because '--outFile' specified index.ts diff --git a/tests/baselines/reference/tsserver/projectReferences/auto-import-with-referenced-project-when-built-with-disableSourceOfProjectReferenceRedirect.js b/tests/baselines/reference/tsserver/projectReferences/auto-import-with-referenced-project-when-built-with-disableSourceOfProjectReferenceRedirect.js index c257c3c0f2e73..d7b7c45b64f85 100644 --- a/tests/baselines/reference/tsserver/projectReferences/auto-import-with-referenced-project-when-built-with-disableSourceOfProjectReferenceRedirect.js +++ b/tests/baselines/reference/tsserver/projectReferences/auto-import-with-referenced-project-when-built-with-disableSourceOfProjectReferenceRedirect.js @@ -68,7 +68,7 @@ Project '/user/username/projects/myproject/app/src/program/tsconfig.json' (Confi ../../../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../../../shared/bld/library/index.d.ts Imported via "shared" from file 'bar.ts' with packageId 'shared/bld/library/index.d.ts@1.0.0' bar.ts diff --git a/tests/baselines/reference/tsserver/projectReferences/auto-import-with-referenced-project-when-built.js b/tests/baselines/reference/tsserver/projectReferences/auto-import-with-referenced-project-when-built.js index 6f7e0f4c7773c..6d2e6ff6b9038 100644 --- a/tests/baselines/reference/tsserver/projectReferences/auto-import-with-referenced-project-when-built.js +++ b/tests/baselines/reference/tsserver/projectReferences/auto-import-with-referenced-project-when-built.js @@ -67,7 +67,7 @@ Project '/user/username/projects/myproject/app/src/program/tsconfig.json' (Confi ../../../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../../../shared/src/library/index.ts Imported via "shared" from file 'bar.ts' with packageId 'shared/bld/library/index.d.ts@1.0.0' bar.ts diff --git a/tests/baselines/reference/tsserver/projectReferences/auto-import-with-referenced-project.js b/tests/baselines/reference/tsserver/projectReferences/auto-import-with-referenced-project.js index 6f7e0f4c7773c..6d2e6ff6b9038 100644 --- a/tests/baselines/reference/tsserver/projectReferences/auto-import-with-referenced-project.js +++ b/tests/baselines/reference/tsserver/projectReferences/auto-import-with-referenced-project.js @@ -67,7 +67,7 @@ Project '/user/username/projects/myproject/app/src/program/tsconfig.json' (Confi ../../../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../../../shared/src/library/index.ts Imported via "shared" from file 'bar.ts' with packageId 'shared/bld/library/index.d.ts@1.0.0' bar.ts diff --git a/tests/baselines/reference/tsserver/projectReferences/can-successfully-find-references-with-out-option.js b/tests/baselines/reference/tsserver/projectReferences/can-successfully-find-references-with-out-option.js index 901557f3c9ef1..1b0c0d2f7c153 100644 --- a/tests/baselines/reference/tsserver/projectReferences/can-successfully-find-references-with-out-option.js +++ b/tests/baselines/reference/tsserver/projectReferences/can-successfully-find-references-with-out-option.js @@ -51,7 +51,7 @@ Project '/user/username/projects/container/compositeExec/tsconfig.json' (Configu ../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../lib/index.ts Source from referenced project '../lib/tsconfig.json' included because '--outFile' specified index.ts @@ -94,7 +94,7 @@ Project '/user/username/projects/container/lib/tsconfig.json' (Configured) ../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' index.ts Part of 'files' list in tsconfig.json @@ -156,7 +156,7 @@ Project '/user/username/projects/container/exec/tsconfig.json' (Configured) ../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../lib/index.ts Source from referenced project '../lib/tsconfig.json' included because '--outFile' specified index.ts diff --git a/tests/baselines/reference/tsserver/projectReferences/disables-looking-into-the-child-project-if-disableReferencedProjectLoad-is-set-in-first-indirect-project-but-not-in-another-one.js b/tests/baselines/reference/tsserver/projectReferences/disables-looking-into-the-child-project-if-disableReferencedProjectLoad-is-set-in-first-indirect-project-but-not-in-another-one.js index 82ed7b753a83d..9a63c26b17209 100644 --- a/tests/baselines/reference/tsserver/projectReferences/disables-looking-into-the-child-project-if-disableReferencedProjectLoad-is-set-in-first-indirect-project-but-not-in-another-one.js +++ b/tests/baselines/reference/tsserver/projectReferences/disables-looking-into-the-child-project-if-disableReferencedProjectLoad-is-set-in-first-indirect-project-but-not-in-another-one.js @@ -101,7 +101,7 @@ Project '/user/username/projects/myproject/tsconfig-src.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/helpers/functions.ts Imported via 'helpers/functions' from file 'src/main.ts' Matched by include pattern './src/**/*' in 'tsconfig-src.json' @@ -234,7 +234,7 @@ Project '/user/username/projects/myproject/tsconfig-src.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/helpers/functions.ts Imported via 'helpers/functions' from file 'src/main.ts' Matched by include pattern './src/**/*' in 'tsconfig-src.json' @@ -355,7 +355,7 @@ Project '/user/username/projects/myproject/tsconfig-src.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/helpers/functions.ts Imported via 'helpers/functions' from file 'src/main.ts' Matched by include pattern './src/**/*' in 'tsconfig-src.json' diff --git a/tests/baselines/reference/tsserver/projectReferences/disables-looking-into-the-child-project-if-disableReferencedProjectLoad-is-set-in-indirect-project.js b/tests/baselines/reference/tsserver/projectReferences/disables-looking-into-the-child-project-if-disableReferencedProjectLoad-is-set-in-indirect-project.js index 45020c168612c..7e48c98547aa0 100644 --- a/tests/baselines/reference/tsserver/projectReferences/disables-looking-into-the-child-project-if-disableReferencedProjectLoad-is-set-in-indirect-project.js +++ b/tests/baselines/reference/tsserver/projectReferences/disables-looking-into-the-child-project-if-disableReferencedProjectLoad-is-set-in-indirect-project.js @@ -81,7 +81,7 @@ Project '/user/username/projects/myproject/tsconfig-indirect1.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/helpers/functions.ts Imported via 'helpers/functions' from file 'src/main.ts' src/main.ts @@ -214,7 +214,7 @@ Project '/user/username/projects/myproject/tsconfig-indirect1.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/helpers/functions.ts Imported via 'helpers/functions' from file 'src/main.ts' src/main.ts @@ -318,7 +318,7 @@ Project '/user/username/projects/myproject/tsconfig-indirect1.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/helpers/functions.ts Imported via 'helpers/functions' from file 'src/main.ts' src/main.ts diff --git a/tests/baselines/reference/tsserver/projectReferences/does-not-error-on-container-only-project.js b/tests/baselines/reference/tsserver/projectReferences/does-not-error-on-container-only-project.js index d9c6845a1a686..43b8000ef66b6 100644 --- a/tests/baselines/reference/tsserver/projectReferences/does-not-error-on-container-only-project.js +++ b/tests/baselines/reference/tsserver/projectReferences/does-not-error-on-container-only-project.js @@ -49,7 +49,7 @@ Project '/user/username/projects/container/compositeExec/tsconfig.json' (Configu ../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../lib/index.ts Source from referenced project '../lib/tsconfig.json' included because '--outFile' specified index.ts @@ -90,7 +90,7 @@ Project '/user/username/projects/container/exec/tsconfig.json' (Configured) ../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../lib/index.ts Source from referenced project '../lib/tsconfig.json' included because '--outFile' specified index.ts @@ -112,7 +112,7 @@ Project '/user/username/projects/container/lib/tsconfig.json' (Configured) ../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' index.ts Part of 'files' list in tsconfig.json diff --git a/tests/baselines/reference/tsserver/projectReferences/finding-local-reference-doesnt-load-ancestor/sibling-projects.js b/tests/baselines/reference/tsserver/projectReferences/finding-local-reference-doesnt-load-ancestor/sibling-projects.js index b3b922c4b2c3b..e0b4059ce9765 100644 --- a/tests/baselines/reference/tsserver/projectReferences/finding-local-reference-doesnt-load-ancestor/sibling-projects.js +++ b/tests/baselines/reference/tsserver/projectReferences/finding-local-reference-doesnt-load-ancestor/sibling-projects.js @@ -32,7 +32,7 @@ Project '/user/username/projects/solution/compiler/tsconfig.json' (Configured) ../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' types.ts Part of 'files' list in tsconfig.json program.ts @@ -117,7 +117,7 @@ Project '/user/username/projects/solution/services/tsconfig.json' (Configured) ../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../compiler/types.ts Source from referenced project '../compiler/tsconfig.json' included because '--module' is specified as 'none' ../compiler/program.ts diff --git a/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-packageJson-has-types-field-and-has-index.ts-and-solution-is-built-with-preserveSymlinks.js b/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-packageJson-has-types-field-and-has-index.ts-and-solution-is-built-with-preserveSymlinks.js index f969c5b84e566..a9013a77c9bf3 100644 --- a/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-packageJson-has-types-field-and-has-index.ts-and-solution-is-built-with-preserveSymlinks.js +++ b/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-packageJson-has-types-field-and-has-index.ts-and-solution-is-built-with-preserveSymlinks.js @@ -71,7 +71,7 @@ Project '/user/username/projects/myproject/packages/A/tsconfig.json' (Configured ../../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../B/src/index.ts Imported via 'b' from file 'src/index.ts' ../B/src/bar.ts diff --git a/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-packageJson-has-types-field-and-has-index.ts-and-solution-is-built.js b/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-packageJson-has-types-field-and-has-index.ts-and-solution-is-built.js index e60b86b81078d..04e4eb883df31 100644 --- a/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-packageJson-has-types-field-and-has-index.ts-and-solution-is-built.js +++ b/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-packageJson-has-types-field-and-has-index.ts-and-solution-is-built.js @@ -69,7 +69,7 @@ Project '/user/username/projects/myproject/packages/A/tsconfig.json' (Configured ../../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../B/src/index.ts Imported via 'b' from file 'src/index.ts' ../B/src/bar.ts diff --git a/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-packageJson-has-types-field-and-has-index.ts-and-solution-is-not-built-with-preserveSymlinks.js b/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-packageJson-has-types-field-and-has-index.ts-and-solution-is-not-built-with-preserveSymlinks.js index f969c5b84e566..a9013a77c9bf3 100644 --- a/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-packageJson-has-types-field-and-has-index.ts-and-solution-is-not-built-with-preserveSymlinks.js +++ b/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-packageJson-has-types-field-and-has-index.ts-and-solution-is-not-built-with-preserveSymlinks.js @@ -71,7 +71,7 @@ Project '/user/username/projects/myproject/packages/A/tsconfig.json' (Configured ../../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../B/src/index.ts Imported via 'b' from file 'src/index.ts' ../B/src/bar.ts diff --git a/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-packageJson-has-types-field-and-has-index.ts-and-solution-is-not-built.js b/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-packageJson-has-types-field-and-has-index.ts-and-solution-is-not-built.js index e60b86b81078d..04e4eb883df31 100644 --- a/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-packageJson-has-types-field-and-has-index.ts-and-solution-is-not-built.js +++ b/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-packageJson-has-types-field-and-has-index.ts-and-solution-is-not-built.js @@ -69,7 +69,7 @@ Project '/user/username/projects/myproject/packages/A/tsconfig.json' (Configured ../../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../B/src/index.ts Imported via 'b' from file 'src/index.ts' ../B/src/bar.ts diff --git a/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-packageJson-has-types-field-and-has-index.ts-with-scoped-package-and-solution-is-built-with-preserveSymlinks.js b/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-packageJson-has-types-field-and-has-index.ts-with-scoped-package-and-solution-is-built-with-preserveSymlinks.js index 8b26d25ed154a..2f1e96760ad2a 100644 --- a/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-packageJson-has-types-field-and-has-index.ts-with-scoped-package-and-solution-is-built-with-preserveSymlinks.js +++ b/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-packageJson-has-types-field-and-has-index.ts-with-scoped-package-and-solution-is-built-with-preserveSymlinks.js @@ -71,7 +71,7 @@ Project '/user/username/projects/myproject/packages/A/tsconfig.json' (Configured ../../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../B/src/index.ts Imported via '@issue/b' from file 'src/index.ts' ../B/src/bar.ts diff --git a/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-packageJson-has-types-field-and-has-index.ts-with-scoped-package-and-solution-is-built.js b/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-packageJson-has-types-field-and-has-index.ts-with-scoped-package-and-solution-is-built.js index 66046c4b53eb7..ef0145096da1f 100644 --- a/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-packageJson-has-types-field-and-has-index.ts-with-scoped-package-and-solution-is-built.js +++ b/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-packageJson-has-types-field-and-has-index.ts-with-scoped-package-and-solution-is-built.js @@ -69,7 +69,7 @@ Project '/user/username/projects/myproject/packages/A/tsconfig.json' (Configured ../../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../B/src/index.ts Imported via '@issue/b' from file 'src/index.ts' ../B/src/bar.ts diff --git a/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-packageJson-has-types-field-and-has-index.ts-with-scoped-package-and-solution-is-not-built-with-preserveSymlinks.js b/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-packageJson-has-types-field-and-has-index.ts-with-scoped-package-and-solution-is-not-built-with-preserveSymlinks.js index 8b26d25ed154a..2f1e96760ad2a 100644 --- a/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-packageJson-has-types-field-and-has-index.ts-with-scoped-package-and-solution-is-not-built-with-preserveSymlinks.js +++ b/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-packageJson-has-types-field-and-has-index.ts-with-scoped-package-and-solution-is-not-built-with-preserveSymlinks.js @@ -71,7 +71,7 @@ Project '/user/username/projects/myproject/packages/A/tsconfig.json' (Configured ../../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../B/src/index.ts Imported via '@issue/b' from file 'src/index.ts' ../B/src/bar.ts diff --git a/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-packageJson-has-types-field-and-has-index.ts-with-scoped-package-and-solution-is-not-built.js b/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-packageJson-has-types-field-and-has-index.ts-with-scoped-package-and-solution-is-not-built.js index 66046c4b53eb7..ef0145096da1f 100644 --- a/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-packageJson-has-types-field-and-has-index.ts-with-scoped-package-and-solution-is-not-built.js +++ b/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-packageJson-has-types-field-and-has-index.ts-with-scoped-package-and-solution-is-not-built.js @@ -69,7 +69,7 @@ Project '/user/username/projects/myproject/packages/A/tsconfig.json' (Configured ../../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../B/src/index.ts Imported via '@issue/b' from file 'src/index.ts' ../B/src/bar.ts diff --git a/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-referencing-file-from-subFolder-and-solution-is-built-with-preserveSymlinks.js b/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-referencing-file-from-subFolder-and-solution-is-built-with-preserveSymlinks.js index 7726579e91a68..9a61dfad25320 100644 --- a/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-referencing-file-from-subFolder-and-solution-is-built-with-preserveSymlinks.js +++ b/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-referencing-file-from-subFolder-and-solution-is-built-with-preserveSymlinks.js @@ -71,7 +71,7 @@ Project '/user/username/projects/myproject/packages/A/tsconfig.json' (Configured ../../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../B/src/foo.ts Imported via 'b/lib/foo' from file 'src/test.ts' ../B/src/bar/foo.ts diff --git a/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-referencing-file-from-subFolder-and-solution-is-built.js b/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-referencing-file-from-subFolder-and-solution-is-built.js index f22cf5c905156..f6845aa802776 100644 --- a/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-referencing-file-from-subFolder-and-solution-is-built.js +++ b/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-referencing-file-from-subFolder-and-solution-is-built.js @@ -69,7 +69,7 @@ Project '/user/username/projects/myproject/packages/A/tsconfig.json' (Configured ../../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../B/src/foo.ts Imported via 'b/lib/foo' from file 'src/test.ts' ../B/src/bar/foo.ts diff --git a/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-referencing-file-from-subFolder-and-solution-is-not-built-with-preserveSymlinks.js b/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-referencing-file-from-subFolder-and-solution-is-not-built-with-preserveSymlinks.js index 7726579e91a68..9a61dfad25320 100644 --- a/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-referencing-file-from-subFolder-and-solution-is-not-built-with-preserveSymlinks.js +++ b/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-referencing-file-from-subFolder-and-solution-is-not-built-with-preserveSymlinks.js @@ -71,7 +71,7 @@ Project '/user/username/projects/myproject/packages/A/tsconfig.json' (Configured ../../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../B/src/foo.ts Imported via 'b/lib/foo' from file 'src/test.ts' ../B/src/bar/foo.ts diff --git a/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-referencing-file-from-subFolder-and-solution-is-not-built.js b/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-referencing-file-from-subFolder-and-solution-is-not-built.js index f22cf5c905156..f6845aa802776 100644 --- a/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-referencing-file-from-subFolder-and-solution-is-not-built.js +++ b/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-referencing-file-from-subFolder-and-solution-is-not-built.js @@ -69,7 +69,7 @@ Project '/user/username/projects/myproject/packages/A/tsconfig.json' (Configured ../../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../B/src/foo.ts Imported via 'b/lib/foo' from file 'src/test.ts' ../B/src/bar/foo.ts diff --git a/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-referencing-file-from-subFolder-with-scoped-package-and-solution-is-built-with-preserveSymlinks.js b/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-referencing-file-from-subFolder-with-scoped-package-and-solution-is-built-with-preserveSymlinks.js index 85a0c966f68a0..a77a219fa9442 100644 --- a/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-referencing-file-from-subFolder-with-scoped-package-and-solution-is-built-with-preserveSymlinks.js +++ b/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-referencing-file-from-subFolder-with-scoped-package-and-solution-is-built-with-preserveSymlinks.js @@ -71,7 +71,7 @@ Project '/user/username/projects/myproject/packages/A/tsconfig.json' (Configured ../../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../B/src/foo.ts Imported via '@issue/b/lib/foo' from file 'src/test.ts' ../B/src/bar/foo.ts diff --git a/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-referencing-file-from-subFolder-with-scoped-package-and-solution-is-built.js b/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-referencing-file-from-subFolder-with-scoped-package-and-solution-is-built.js index 1ff4238c7230d..8cd1d9f315d28 100644 --- a/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-referencing-file-from-subFolder-with-scoped-package-and-solution-is-built.js +++ b/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-referencing-file-from-subFolder-with-scoped-package-and-solution-is-built.js @@ -69,7 +69,7 @@ Project '/user/username/projects/myproject/packages/A/tsconfig.json' (Configured ../../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../B/src/foo.ts Imported via '@issue/b/lib/foo' from file 'src/test.ts' ../B/src/bar/foo.ts diff --git a/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-referencing-file-from-subFolder-with-scoped-package-and-solution-is-not-built-with-preserveSymlinks.js b/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-referencing-file-from-subFolder-with-scoped-package-and-solution-is-not-built-with-preserveSymlinks.js index 85a0c966f68a0..a77a219fa9442 100644 --- a/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-referencing-file-from-subFolder-with-scoped-package-and-solution-is-not-built-with-preserveSymlinks.js +++ b/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-referencing-file-from-subFolder-with-scoped-package-and-solution-is-not-built-with-preserveSymlinks.js @@ -71,7 +71,7 @@ Project '/user/username/projects/myproject/packages/A/tsconfig.json' (Configured ../../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../B/src/foo.ts Imported via '@issue/b/lib/foo' from file 'src/test.ts' ../B/src/bar/foo.ts diff --git a/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-referencing-file-from-subFolder-with-scoped-package-and-solution-is-not-built.js b/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-referencing-file-from-subFolder-with-scoped-package-and-solution-is-not-built.js index 1ff4238c7230d..8cd1d9f315d28 100644 --- a/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-referencing-file-from-subFolder-with-scoped-package-and-solution-is-not-built.js +++ b/tests/baselines/reference/tsserver/projectReferences/monorepo-like-with-symlinks-when-referencing-file-from-subFolder-with-scoped-package-and-solution-is-not-built.js @@ -69,7 +69,7 @@ Project '/user/username/projects/myproject/packages/A/tsconfig.json' (Configured ../../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../B/src/foo.ts Imported via '@issue/b/lib/foo' from file 'src/test.ts' ../B/src/bar/foo.ts diff --git a/tests/baselines/reference/tsserver/projectReferences/new-file-is-added-to-the-referenced-project-when-referenced-project-is-not-open-with-disableSourceOfProjectReferenceRedirect.js b/tests/baselines/reference/tsserver/projectReferences/new-file-is-added-to-the-referenced-project-when-referenced-project-is-not-open-with-disableSourceOfProjectReferenceRedirect.js index 6067b76e4445c..33ff2899bb102 100644 --- a/tests/baselines/reference/tsserver/projectReferences/new-file-is-added-to-the-referenced-project-when-referenced-project-is-not-open-with-disableSourceOfProjectReferenceRedirect.js +++ b/tests/baselines/reference/tsserver/projectReferences/new-file-is-added-to-the-referenced-project-when-referenced-project-is-not-open-with-disableSourceOfProjectReferenceRedirect.js @@ -55,7 +55,7 @@ Project '/user/username/projects/myproject/projects/project2/tsconfig.json' (Con ../../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../project1/class1.d.ts Output from referenced project '../project1/tsconfig.json' included because '--module' is specified as 'none' class2.ts @@ -119,7 +119,7 @@ Project '/user/username/projects/myproject/projects/project2/tsconfig.json' (Con ../../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../project1/class1.d.ts Output from referenced project '../project1/tsconfig.json' included because '--module' is specified as 'none' ../project1/class3.d.ts @@ -171,7 +171,7 @@ Project '/user/username/projects/myproject/projects/project2/tsconfig.json' (Con ../../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../project1/class1.d.ts Output from referenced project '../project1/tsconfig.json' included because '--module' is specified as 'none' class2.ts @@ -216,7 +216,7 @@ Project '/user/username/projects/myproject/projects/project2/tsconfig.json' (Con ../../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../project1/class1.d.ts Output from referenced project '../project1/tsconfig.json' included because '--module' is specified as 'none' ../project1/class3.d.ts diff --git a/tests/baselines/reference/tsserver/projectReferences/new-file-is-added-to-the-referenced-project-when-referenced-project-is-not-open.js b/tests/baselines/reference/tsserver/projectReferences/new-file-is-added-to-the-referenced-project-when-referenced-project-is-not-open.js index b49dd3463821d..b7dd8d659e8cd 100644 --- a/tests/baselines/reference/tsserver/projectReferences/new-file-is-added-to-the-referenced-project-when-referenced-project-is-not-open.js +++ b/tests/baselines/reference/tsserver/projectReferences/new-file-is-added-to-the-referenced-project-when-referenced-project-is-not-open.js @@ -54,7 +54,7 @@ Project '/user/username/projects/myproject/projects/project2/tsconfig.json' (Con ../../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../project1/class1.ts Source from referenced project '../project1/tsconfig.json' included because '--module' is specified as 'none' class2.ts @@ -88,7 +88,7 @@ Project '/user/username/projects/myproject/projects/project2/tsconfig.json' (Con ../../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../project1/class1.ts Source from referenced project '../project1/tsconfig.json' included because '--module' is specified as 'none' ../project1/class3.ts diff --git a/tests/baselines/reference/tsserver/projectReferences/new-file-is-added-to-the-referenced-project-when-referenced-project-is-open-with-disableSourceOfProjectReferenceRedirect.js b/tests/baselines/reference/tsserver/projectReferences/new-file-is-added-to-the-referenced-project-when-referenced-project-is-open-with-disableSourceOfProjectReferenceRedirect.js index e17a9ec7915e3..7f2d161a7d719 100644 --- a/tests/baselines/reference/tsserver/projectReferences/new-file-is-added-to-the-referenced-project-when-referenced-project-is-open-with-disableSourceOfProjectReferenceRedirect.js +++ b/tests/baselines/reference/tsserver/projectReferences/new-file-is-added-to-the-referenced-project-when-referenced-project-is-open-with-disableSourceOfProjectReferenceRedirect.js @@ -55,7 +55,7 @@ Project '/user/username/projects/myproject/projects/project2/tsconfig.json' (Con ../../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../project1/class1.d.ts Output from referenced project '../project1/tsconfig.json' included because '--module' is specified as 'none' class2.ts @@ -92,7 +92,7 @@ Project '/user/username/projects/myproject/projects/project1/tsconfig.json' (Con ../../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' class1.ts Matched by include pattern '**/*' in 'tsconfig.json' @@ -136,7 +136,7 @@ Project '/user/username/projects/myproject/projects/project1/tsconfig.json' (Con ../../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' class1.ts Matched by include pattern '**/*' in 'tsconfig.json' class3.ts @@ -193,7 +193,7 @@ Project '/user/username/projects/myproject/projects/project2/tsconfig.json' (Con ../../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../project1/class1.d.ts Output from referenced project '../project1/tsconfig.json' included because '--module' is specified as 'none' ../project1/class3.d.ts @@ -257,7 +257,7 @@ Project '/user/username/projects/myproject/projects/project2/tsconfig.json' (Con ../../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../project1/class1.d.ts Output from referenced project '../project1/tsconfig.json' included because '--module' is specified as 'none' class2.ts @@ -314,7 +314,7 @@ Project '/user/username/projects/myproject/projects/project2/tsconfig.json' (Con ../../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../project1/class1.d.ts Output from referenced project '../project1/tsconfig.json' included because '--module' is specified as 'none' ../project1/class3.d.ts diff --git a/tests/baselines/reference/tsserver/projectReferences/new-file-is-added-to-the-referenced-project-when-referenced-project-is-open.js b/tests/baselines/reference/tsserver/projectReferences/new-file-is-added-to-the-referenced-project-when-referenced-project-is-open.js index 6d615c5d9cca1..e599b581ce232 100644 --- a/tests/baselines/reference/tsserver/projectReferences/new-file-is-added-to-the-referenced-project-when-referenced-project-is-open.js +++ b/tests/baselines/reference/tsserver/projectReferences/new-file-is-added-to-the-referenced-project-when-referenced-project-is-open.js @@ -54,7 +54,7 @@ Project '/user/username/projects/myproject/projects/project2/tsconfig.json' (Con ../../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../project1/class1.ts Source from referenced project '../project1/tsconfig.json' included because '--module' is specified as 'none' class2.ts @@ -92,7 +92,7 @@ Project '/user/username/projects/myproject/projects/project1/tsconfig.json' (Con ../../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' class1.ts Matched by include pattern '**/*' in 'tsconfig.json' @@ -132,7 +132,7 @@ Project '/user/username/projects/myproject/projects/project2/tsconfig.json' (Con ../../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../project1/class1.ts Source from referenced project '../project1/tsconfig.json' included because '--module' is specified as 'none' ../project1/class3.ts @@ -152,7 +152,7 @@ Project '/user/username/projects/myproject/projects/project1/tsconfig.json' (Con ../../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' class1.ts Matched by include pattern '**/*' in 'tsconfig.json' class3.ts diff --git a/tests/baselines/reference/tsserver/projectReferences/project-is-directly-referenced-by-solution.js b/tests/baselines/reference/tsserver/projectReferences/project-is-directly-referenced-by-solution.js index 0491fc90397c8..733f44198e166 100644 --- a/tests/baselines/reference/tsserver/projectReferences/project-is-directly-referenced-by-solution.js +++ b/tests/baselines/reference/tsserver/projectReferences/project-is-directly-referenced-by-solution.js @@ -60,7 +60,7 @@ Project '/user/username/projects/myproject/tsconfig-src.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/helpers/functions.ts Imported via 'helpers/functions' from file 'src/main.ts' Matched by include pattern './src/**/*' in 'tsconfig-src.json' @@ -201,7 +201,7 @@ Project '/user/username/projects/myproject/tsconfig-src.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/helpers/functions.ts Imported via 'helpers/functions' from file 'src/main.ts' Matched by include pattern './src/**/*' in 'tsconfig-src.json' @@ -281,7 +281,7 @@ Project '/user/username/projects/myproject/tsconfig-src.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/helpers/functions.ts Imported via 'helpers/functions' from file 'src/main.ts' Matched by include pattern './src/**/*' in 'tsconfig-src.json' @@ -537,7 +537,7 @@ Project '/user/username/projects/myproject/indirect3/tsconfig.json' (Configured) ../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../target/src/helpers/functions.d.ts Imported via 'helpers/functions' from file '../target/src/main.d.ts' ../target/src/main.d.ts @@ -571,7 +571,7 @@ Project '/user/username/projects/myproject/tsconfig-src.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/helpers/functions.ts Imported via 'helpers/functions' from file 'src/main.ts' Matched by include pattern './src/**/*' in 'tsconfig-src.json' @@ -668,7 +668,7 @@ Project '/user/username/projects/myproject/tsconfig-src.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/helpers/functions.ts Imported via 'helpers/functions' from file 'src/main.ts' Matched by include pattern './src/**/*' in 'tsconfig-src.json' diff --git a/tests/baselines/reference/tsserver/projectReferences/project-is-indirectly-referenced-by-solution.js b/tests/baselines/reference/tsserver/projectReferences/project-is-indirectly-referenced-by-solution.js index 1fc3aca66dd00..f98f0ac84e7ad 100644 --- a/tests/baselines/reference/tsserver/projectReferences/project-is-indirectly-referenced-by-solution.js +++ b/tests/baselines/reference/tsserver/projectReferences/project-is-indirectly-referenced-by-solution.js @@ -100,7 +100,7 @@ Project '/user/username/projects/myproject/tsconfig-src.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/helpers/functions.ts Imported via 'helpers/functions' from file 'src/main.ts' Matched by include pattern './src/**/*' in 'tsconfig-src.json' @@ -243,7 +243,7 @@ Project '/user/username/projects/myproject/tsconfig-src.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/helpers/functions.ts Imported via 'helpers/functions' from file 'src/main.ts' Matched by include pattern './src/**/*' in 'tsconfig-src.json' @@ -363,7 +363,7 @@ Project '/user/username/projects/myproject/tsconfig-src.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/helpers/functions.ts Imported via 'helpers/functions' from file 'src/main.ts' Matched by include pattern './src/**/*' in 'tsconfig-src.json' @@ -606,7 +606,7 @@ Project '/user/username/projects/myproject/tsconfig-indirect1.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/helpers/functions.ts Imported via 'helpers/functions' from file 'src/main.ts' src/main.ts @@ -637,7 +637,7 @@ Project '/user/username/projects/myproject/tsconfig-indirect2.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/helpers/functions.ts Imported via 'helpers/functions' from file 'src/main.ts' src/main.ts @@ -743,7 +743,7 @@ Project '/user/username/projects/myproject/indirect3/tsconfig.json' (Configured) ../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../target/src/helpers/functions.d.ts Imported via 'helpers/functions' from file '../target/src/main.d.ts' ../target/src/main.d.ts @@ -777,7 +777,7 @@ Project '/user/username/projects/myproject/tsconfig-src.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/helpers/functions.ts Imported via 'helpers/functions' from file 'src/main.ts' Matched by include pattern './src/**/*' in 'tsconfig-src.json' @@ -797,7 +797,7 @@ Project '/user/username/projects/myproject/tsconfig-indirect1.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/helpers/functions.ts Imported via 'helpers/functions' from file 'src/main.ts' src/main.ts @@ -819,7 +819,7 @@ Project '/user/username/projects/myproject/tsconfig-indirect2.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/helpers/functions.ts Imported via 'helpers/functions' from file 'src/main.ts' src/main.ts @@ -960,7 +960,7 @@ Project '/user/username/projects/myproject/tsconfig-src.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/helpers/functions.ts Imported via 'helpers/functions' from file 'src/main.ts' Matched by include pattern './src/**/*' in 'tsconfig-src.json' @@ -996,7 +996,7 @@ Project '/user/username/projects/myproject/tsconfig-indirect1.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/helpers/functions.ts Imported via 'helpers/functions' from file 'src/main.ts' src/main.ts @@ -1025,7 +1025,7 @@ Project '/user/username/projects/myproject/tsconfig-indirect2.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/helpers/functions.ts Imported via 'helpers/functions' from file 'src/main.ts' src/main.ts diff --git a/tests/baselines/reference/tsserver/projectReferences/root-file-is-file-from-referenced-project-and-using-declaration-maps.js b/tests/baselines/reference/tsserver/projectReferences/root-file-is-file-from-referenced-project-and-using-declaration-maps.js index 0730f12780e09..7b780c70d9461 100644 --- a/tests/baselines/reference/tsserver/projectReferences/root-file-is-file-from-referenced-project-and-using-declaration-maps.js +++ b/tests/baselines/reference/tsserver/projectReferences/root-file-is-file-from-referenced-project-and-using-declaration-maps.js @@ -39,7 +39,7 @@ Project '/user/username/projects/project/src/common/tsconfig.json' (Configured) ../../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' input/keyboard.ts Imported via 'common/input/keyboard' from file 'input/keyboard.test.ts' Matched by include pattern './**/*' in 'tsconfig.json' @@ -116,7 +116,7 @@ Project '/user/username/projects/project/src/tsconfig.json' (Configured) ../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../out/input/keyboard.d.ts Imported via 'common/input/keyboard' from file 'terminal.ts' Imported via 'common/input/keyboard' from file 'common/input/keyboard.test.ts' diff --git a/tests/baselines/reference/tsserver/projectReferences/root-file-is-file-from-referenced-project.js b/tests/baselines/reference/tsserver/projectReferences/root-file-is-file-from-referenced-project.js index 6c9ab0042f3ae..087b11925fd3f 100644 --- a/tests/baselines/reference/tsserver/projectReferences/root-file-is-file-from-referenced-project.js +++ b/tests/baselines/reference/tsserver/projectReferences/root-file-is-file-from-referenced-project.js @@ -39,7 +39,7 @@ Project '/user/username/projects/project/src/common/tsconfig.json' (Configured) ../../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' input/keyboard.ts Imported via 'common/input/keyboard' from file 'input/keyboard.test.ts' Matched by include pattern './**/*' in 'tsconfig.json' @@ -115,7 +115,7 @@ Project '/user/username/projects/project/src/tsconfig.json' (Configured) ../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' common/input/keyboard.ts Imported via 'common/input/keyboard' from file 'terminal.ts' Imported via 'common/input/keyboard' from file 'common/input/keyboard.test.ts' diff --git a/tests/baselines/reference/tsserver/projectReferences/solution-with-its-own-files-and-disables-looking-into-the-child-project-if-disableReferencedProjectLoad-is-set-in-first-indirect-project-but-not-in-another-one.js b/tests/baselines/reference/tsserver/projectReferences/solution-with-its-own-files-and-disables-looking-into-the-child-project-if-disableReferencedProjectLoad-is-set-in-first-indirect-project-but-not-in-another-one.js index 409f4ec3ab500..9ccdf36a3e7d8 100644 --- a/tests/baselines/reference/tsserver/projectReferences/solution-with-its-own-files-and-disables-looking-into-the-child-project-if-disableReferencedProjectLoad-is-set-in-first-indirect-project-but-not-in-another-one.js +++ b/tests/baselines/reference/tsserver/projectReferences/solution-with-its-own-files-and-disables-looking-into-the-child-project-if-disableReferencedProjectLoad-is-set-in-first-indirect-project-but-not-in-another-one.js @@ -96,7 +96,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/helpers/functions.ts Imported via 'helpers/functions' from file 'src/main.ts' src/main.ts @@ -127,7 +127,7 @@ Project '/user/username/projects/myproject/tsconfig-src.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/helpers/functions.ts Imported via 'helpers/functions' from file 'src/main.ts' Matched by include pattern './src/**/*' in 'tsconfig-src.json' @@ -250,7 +250,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/helpers/functions.ts Imported via 'helpers/functions' from file 'src/main.ts' src/main.ts @@ -275,7 +275,7 @@ Project '/user/username/projects/myproject/tsconfig-src.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/helpers/functions.ts Imported via 'helpers/functions' from file 'src/main.ts' Matched by include pattern './src/**/*' in 'tsconfig-src.json' @@ -395,7 +395,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/helpers/functions.ts Imported via 'helpers/functions' from file 'src/main.ts' src/main.ts @@ -424,7 +424,7 @@ Project '/user/username/projects/myproject/tsconfig-src.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/helpers/functions.ts Imported via 'helpers/functions' from file 'src/main.ts' Matched by include pattern './src/**/*' in 'tsconfig-src.json' diff --git a/tests/baselines/reference/tsserver/projectReferences/solution-with-its-own-files-and-disables-looking-into-the-child-project-if-disableReferencedProjectLoad-is-set-in-indirect-project.js b/tests/baselines/reference/tsserver/projectReferences/solution-with-its-own-files-and-disables-looking-into-the-child-project-if-disableReferencedProjectLoad-is-set-in-indirect-project.js index 657f545b7bd0b..3ff42e8c78ea1 100644 --- a/tests/baselines/reference/tsserver/projectReferences/solution-with-its-own-files-and-disables-looking-into-the-child-project-if-disableReferencedProjectLoad-is-set-in-indirect-project.js +++ b/tests/baselines/reference/tsserver/projectReferences/solution-with-its-own-files-and-disables-looking-into-the-child-project-if-disableReferencedProjectLoad-is-set-in-indirect-project.js @@ -74,7 +74,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/helpers/functions.ts Imported via 'helpers/functions' from file 'src/main.ts' src/main.ts @@ -106,7 +106,7 @@ Project '/user/username/projects/myproject/tsconfig-indirect1.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/helpers/functions.ts Imported via 'helpers/functions' from file 'src/main.ts' src/main.ts @@ -230,7 +230,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/helpers/functions.ts Imported via 'helpers/functions' from file 'src/main.ts' src/main.ts @@ -254,7 +254,7 @@ Project '/user/username/projects/myproject/tsconfig-indirect1.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/helpers/functions.ts Imported via 'helpers/functions' from file 'src/main.ts' src/main.ts @@ -354,7 +354,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/helpers/functions.ts Imported via 'helpers/functions' from file 'src/main.ts' src/main.ts @@ -384,7 +384,7 @@ Project '/user/username/projects/myproject/tsconfig-indirect1.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/helpers/functions.ts Imported via 'helpers/functions' from file 'src/main.ts' src/main.ts diff --git a/tests/baselines/reference/tsserver/projectReferences/solution-with-its-own-files-and-disables-looking-into-the-child-project-if-disableReferencedProjectLoad-is-set.js b/tests/baselines/reference/tsserver/projectReferences/solution-with-its-own-files-and-disables-looking-into-the-child-project-if-disableReferencedProjectLoad-is-set.js index 7bacd99ea0871..777ac2ad63b24 100644 --- a/tests/baselines/reference/tsserver/projectReferences/solution-with-its-own-files-and-disables-looking-into-the-child-project-if-disableReferencedProjectLoad-is-set.js +++ b/tests/baselines/reference/tsserver/projectReferences/solution-with-its-own-files-and-disables-looking-into-the-child-project-if-disableReferencedProjectLoad-is-set.js @@ -54,7 +54,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/helpers/functions.ts Imported via 'helpers/functions' from file 'src/main.ts' src/main.ts @@ -161,7 +161,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/helpers/functions.ts Imported via 'helpers/functions' from file 'src/main.ts' src/main.ts @@ -240,7 +240,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/helpers/functions.ts Imported via 'helpers/functions' from file 'src/main.ts' src/main.ts diff --git a/tests/baselines/reference/tsserver/projectReferences/solution-with-its-own-files-and-project-found-is-not-solution-but-references-open-file-through-project-reference.js b/tests/baselines/reference/tsserver/projectReferences/solution-with-its-own-files-and-project-found-is-not-solution-but-references-open-file-through-project-reference.js index 5e41243f1dbdc..557538b6f45e1 100644 --- a/tests/baselines/reference/tsserver/projectReferences/solution-with-its-own-files-and-project-found-is-not-solution-but-references-open-file-through-project-reference.js +++ b/tests/baselines/reference/tsserver/projectReferences/solution-with-its-own-files-and-project-found-is-not-solution-but-references-open-file-through-project-reference.js @@ -53,7 +53,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/helpers/functions.ts Imported via 'helpers/functions' from file 'src/main.ts' src/main.ts @@ -82,7 +82,7 @@ Project '/user/username/projects/myproject/tsconfig-src.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/helpers/functions.ts Imported via 'helpers/functions' from file 'src/main.ts' Matched by include pattern './src/**/*' in 'tsconfig-src.json' @@ -214,7 +214,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/helpers/functions.ts Imported via 'helpers/functions' from file 'src/main.ts' src/main.ts @@ -235,7 +235,7 @@ Project '/user/username/projects/myproject/tsconfig-src.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/helpers/functions.ts Imported via 'helpers/functions' from file 'src/main.ts' Matched by include pattern './src/**/*' in 'tsconfig-src.json' @@ -311,7 +311,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/helpers/functions.ts Imported via 'helpers/functions' from file 'src/main.ts' src/main.ts @@ -338,7 +338,7 @@ Project '/user/username/projects/myproject/tsconfig-src.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/helpers/functions.ts Imported via 'helpers/functions' from file 'src/main.ts' Matched by include pattern './src/**/*' in 'tsconfig-src.json' @@ -612,7 +612,7 @@ Project '/user/username/projects/myproject/indirect3/tsconfig.json' (Configured) ../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../target/src/helpers/functions.d.ts Imported via 'helpers/functions' from file '../target/src/main.d.ts' ../target/src/main.d.ts @@ -637,7 +637,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/helpers/functions.ts Imported via 'helpers/functions' from file 'src/main.ts' src/main.ts @@ -658,7 +658,7 @@ Project '/user/username/projects/myproject/tsconfig-src.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/helpers/functions.ts Imported via 'helpers/functions' from file 'src/main.ts' Matched by include pattern './src/**/*' in 'tsconfig-src.json' @@ -751,7 +751,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/helpers/functions.ts Imported via 'helpers/functions' from file 'src/main.ts' src/main.ts @@ -778,7 +778,7 @@ Project '/user/username/projects/myproject/tsconfig-src.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/helpers/functions.ts Imported via 'helpers/functions' from file 'src/main.ts' Matched by include pattern './src/**/*' in 'tsconfig-src.json' diff --git a/tests/baselines/reference/tsserver/projectReferences/solution-with-its-own-files-and-project-is-indirectly-referenced-by-solution.js b/tests/baselines/reference/tsserver/projectReferences/solution-with-its-own-files-and-project-is-indirectly-referenced-by-solution.js index ae073122bf4a7..172371c9136b7 100644 --- a/tests/baselines/reference/tsserver/projectReferences/solution-with-its-own-files-and-project-is-indirectly-referenced-by-solution.js +++ b/tests/baselines/reference/tsserver/projectReferences/solution-with-its-own-files-and-project-is-indirectly-referenced-by-solution.js @@ -95,7 +95,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/helpers/functions.ts Imported via 'helpers/functions' from file 'src/main.ts' src/main.ts @@ -126,7 +126,7 @@ Project '/user/username/projects/myproject/tsconfig-src.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/helpers/functions.ts Imported via 'helpers/functions' from file 'src/main.ts' Matched by include pattern './src/**/*' in 'tsconfig-src.json' @@ -259,7 +259,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/helpers/functions.ts Imported via 'helpers/functions' from file 'src/main.ts' src/main.ts @@ -284,7 +284,7 @@ Project '/user/username/projects/myproject/tsconfig-src.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/helpers/functions.ts Imported via 'helpers/functions' from file 'src/main.ts' Matched by include pattern './src/**/*' in 'tsconfig-src.json' @@ -403,7 +403,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/helpers/functions.ts Imported via 'helpers/functions' from file 'src/main.ts' src/main.ts @@ -432,7 +432,7 @@ Project '/user/username/projects/myproject/tsconfig-src.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/helpers/functions.ts Imported via 'helpers/functions' from file 'src/main.ts' Matched by include pattern './src/**/*' in 'tsconfig-src.json' @@ -696,7 +696,7 @@ Project '/user/username/projects/myproject/tsconfig-indirect1.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/helpers/functions.ts Imported via 'helpers/functions' from file 'src/main.ts' src/main.ts @@ -735,7 +735,7 @@ Project '/user/username/projects/myproject/tsconfig-indirect2.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/helpers/functions.ts Imported via 'helpers/functions' from file 'src/main.ts' src/main.ts @@ -841,7 +841,7 @@ Project '/user/username/projects/myproject/indirect3/tsconfig.json' (Configured) ../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../target/src/helpers/functions.d.ts Imported via 'helpers/functions' from file '../target/src/main.d.ts' ../target/src/main.d.ts @@ -867,7 +867,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/helpers/functions.ts Imported via 'helpers/functions' from file 'src/main.ts' src/main.ts @@ -890,7 +890,7 @@ Project '/user/username/projects/myproject/tsconfig-src.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/helpers/functions.ts Imported via 'helpers/functions' from file 'src/main.ts' Matched by include pattern './src/**/*' in 'tsconfig-src.json' @@ -910,7 +910,7 @@ Project '/user/username/projects/myproject/tsconfig-indirect1.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/helpers/functions.ts Imported via 'helpers/functions' from file 'src/main.ts' src/main.ts @@ -932,7 +932,7 @@ Project '/user/username/projects/myproject/tsconfig-indirect2.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/helpers/functions.ts Imported via 'helpers/functions' from file 'src/main.ts' src/main.ts @@ -1071,7 +1071,7 @@ Project '/user/username/projects/myproject/tsconfig.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/helpers/functions.ts Imported via 'helpers/functions' from file 'src/main.ts' src/main.ts @@ -1100,7 +1100,7 @@ Project '/user/username/projects/myproject/tsconfig-src.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/helpers/functions.ts Imported via 'helpers/functions' from file 'src/main.ts' Matched by include pattern './src/**/*' in 'tsconfig-src.json' @@ -1135,7 +1135,7 @@ Project '/user/username/projects/myproject/tsconfig-indirect1.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/helpers/functions.ts Imported via 'helpers/functions' from file 'src/main.ts' src/main.ts @@ -1164,7 +1164,7 @@ Project '/user/username/projects/myproject/tsconfig-indirect2.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/helpers/functions.ts Imported via 'helpers/functions' from file 'src/main.ts' src/main.ts diff --git a/tests/baselines/reference/tsserver/projectReferences/special-handling-of-localness-when-using-arrow-function-as-object-literal-property-types.js b/tests/baselines/reference/tsserver/projectReferences/special-handling-of-localness-when-using-arrow-function-as-object-literal-property-types.js index 4952ad577f57a..05dbc65c8940c 100644 --- a/tests/baselines/reference/tsserver/projectReferences/special-handling-of-localness-when-using-arrow-function-as-object-literal-property-types.js +++ b/tests/baselines/reference/tsserver/projectReferences/special-handling-of-localness-when-using-arrow-function-as-object-literal-property-types.js @@ -56,7 +56,7 @@ Project '/user/username/projects/solution/api/tsconfig.json' (Configured) ../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../shared/src/index.ts Imported via "../../shared/dist" from file 'src/server.ts' src/server.ts @@ -99,7 +99,7 @@ Project '/user/username/projects/solution/shared/tsconfig.json' (Configured) ../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/index.ts Matched by include pattern 'src' in 'tsconfig.json' @@ -168,7 +168,7 @@ Project '/user/username/projects/solution/app/tsconfig.json' (Configured) ../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../shared/src/index.ts Imported via "../../shared/dist" from file 'src/app.ts' src/app.ts diff --git a/tests/baselines/reference/tsserver/projectReferences/special-handling-of-localness-when-using-arrow-function-as-object-literal-property.js b/tests/baselines/reference/tsserver/projectReferences/special-handling-of-localness-when-using-arrow-function-as-object-literal-property.js index a38fee1014521..002fd13a1027c 100644 --- a/tests/baselines/reference/tsserver/projectReferences/special-handling-of-localness-when-using-arrow-function-as-object-literal-property.js +++ b/tests/baselines/reference/tsserver/projectReferences/special-handling-of-localness-when-using-arrow-function-as-object-literal-property.js @@ -56,7 +56,7 @@ Project '/user/username/projects/solution/api/tsconfig.json' (Configured) ../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../shared/src/index.ts Imported via "../../shared/dist" from file 'src/server.ts' src/server.ts @@ -99,7 +99,7 @@ Project '/user/username/projects/solution/shared/tsconfig.json' (Configured) ../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/index.ts Matched by include pattern 'src' in 'tsconfig.json' diff --git a/tests/baselines/reference/tsserver/projectReferences/special-handling-of-localness-when-using-arrow-function-assignment.js b/tests/baselines/reference/tsserver/projectReferences/special-handling-of-localness-when-using-arrow-function-assignment.js index 9d7bd0466e250..94d141350d905 100644 --- a/tests/baselines/reference/tsserver/projectReferences/special-handling-of-localness-when-using-arrow-function-assignment.js +++ b/tests/baselines/reference/tsserver/projectReferences/special-handling-of-localness-when-using-arrow-function-assignment.js @@ -56,7 +56,7 @@ Project '/user/username/projects/solution/api/tsconfig.json' (Configured) ../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../shared/src/index.ts Imported via "../../shared/dist" from file 'src/server.ts' src/server.ts @@ -99,7 +99,7 @@ Project '/user/username/projects/solution/shared/tsconfig.json' (Configured) ../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/index.ts Matched by include pattern 'src' in 'tsconfig.json' @@ -168,7 +168,7 @@ Project '/user/username/projects/solution/app/tsconfig.json' (Configured) ../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../shared/src/index.ts Imported via "../../shared/dist" from file 'src/app.ts' src/app.ts diff --git a/tests/baselines/reference/tsserver/projectReferences/special-handling-of-localness-when-using-method-of-class-expression.js b/tests/baselines/reference/tsserver/projectReferences/special-handling-of-localness-when-using-method-of-class-expression.js index 08ead42ba29b1..90ba1f57746a1 100644 --- a/tests/baselines/reference/tsserver/projectReferences/special-handling-of-localness-when-using-method-of-class-expression.js +++ b/tests/baselines/reference/tsserver/projectReferences/special-handling-of-localness-when-using-method-of-class-expression.js @@ -56,7 +56,7 @@ Project '/user/username/projects/solution/api/tsconfig.json' (Configured) ../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../shared/src/index.ts Imported via "../../shared/dist" from file 'src/server.ts' src/server.ts @@ -99,7 +99,7 @@ Project '/user/username/projects/solution/shared/tsconfig.json' (Configured) ../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/index.ts Matched by include pattern 'src' in 'tsconfig.json' @@ -168,7 +168,7 @@ Project '/user/username/projects/solution/app/tsconfig.json' (Configured) ../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../shared/src/index.ts Imported via "../../shared/dist" from file 'src/app.ts' src/app.ts diff --git a/tests/baselines/reference/tsserver/projectReferences/special-handling-of-localness-when-using-object-literal-property.js b/tests/baselines/reference/tsserver/projectReferences/special-handling-of-localness-when-using-object-literal-property.js index 4bad4c371a6fa..08dfbe0bb76f3 100644 --- a/tests/baselines/reference/tsserver/projectReferences/special-handling-of-localness-when-using-object-literal-property.js +++ b/tests/baselines/reference/tsserver/projectReferences/special-handling-of-localness-when-using-object-literal-property.js @@ -56,7 +56,7 @@ Project '/user/username/projects/solution/api/tsconfig.json' (Configured) ../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../shared/src/index.ts Imported via "../../shared/dist" from file 'src/server.ts' src/server.ts @@ -99,7 +99,7 @@ Project '/user/username/projects/solution/shared/tsconfig.json' (Configured) ../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/index.ts Matched by include pattern 'src' in 'tsconfig.json' @@ -168,7 +168,7 @@ Project '/user/username/projects/solution/app/tsconfig.json' (Configured) ../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../shared/src/index.ts Imported via "../../shared/dist" from file 'src/app.ts' src/app.ts diff --git a/tests/baselines/reference/tsserver/projectReferences/when-files-from-two-projects-are-open-and-one-project-references.js b/tests/baselines/reference/tsserver/projectReferences/when-files-from-two-projects-are-open-and-one-project-references.js index 4c42d2445d25b..f4b045872292a 100644 --- a/tests/baselines/reference/tsserver/projectReferences/when-files-from-two-projects-are-open-and-one-project-references.js +++ b/tests/baselines/reference/tsserver/projectReferences/when-files-from-two-projects-are-open-and-one-project-references.js @@ -242,7 +242,7 @@ Project '/user/username/projects/myproject/main/tsconfig.json' (Configured) ../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/file1.ts Matched by include pattern '**/*' in 'tsconfig.json' @@ -275,7 +275,7 @@ Project '/user/username/projects/myproject/core/tsconfig.json' (Configured) ../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/file1.ts Matched by include pattern '**/*' in 'tsconfig.json' @@ -313,7 +313,7 @@ Project '/user/username/projects/myproject/indirect/tsconfig.json' (Configured) ../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/file1.ts Matched by include pattern '**/*' in 'tsconfig.json' @@ -334,7 +334,7 @@ Project '/user/username/projects/myproject/coreRef1/tsconfig.json' (Configured) ../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/file1.ts Matched by include pattern '**/*' in 'tsconfig.json' @@ -355,7 +355,7 @@ Project '/user/username/projects/myproject/indirectDisabledChildLoad1/tsconfig.j ../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/file1.ts Matched by include pattern '**/*' in 'tsconfig.json' @@ -376,7 +376,7 @@ Project '/user/username/projects/myproject/indirectDisabledChildLoad2/tsconfig.j ../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/file1.ts Matched by include pattern '**/*' in 'tsconfig.json' @@ -397,7 +397,7 @@ Project '/user/username/projects/myproject/refToCoreRef3/tsconfig.json' (Configu ../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/file1.ts Matched by include pattern '**/*' in 'tsconfig.json' @@ -418,7 +418,7 @@ Project '/user/username/projects/myproject/coreRef3/tsconfig.json' (Configured) ../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/file1.ts Matched by include pattern '**/*' in 'tsconfig.json' diff --git a/tests/baselines/reference/tsserver/projectReferences/when-the-referenced-projects-have-allowJs-and-emitDeclarationOnly.js b/tests/baselines/reference/tsserver/projectReferences/when-the-referenced-projects-have-allowJs-and-emitDeclarationOnly.js index 37b36b07abe29..dc9685be6c87c 100644 --- a/tests/baselines/reference/tsserver/projectReferences/when-the-referenced-projects-have-allowJs-and-emitDeclarationOnly.js +++ b/tests/baselines/reference/tsserver/projectReferences/when-the-referenced-projects-have-allowJs-and-emitDeclarationOnly.js @@ -70,7 +70,7 @@ Project '/user/username/projects/myproject/packages/consumer/tsconfig.json' (Con ../../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../emit-composite/src/testModule.js Imported via './testModule' from file '../emit-composite/src/index.js' ../emit-composite/src/index.js diff --git a/tests/baselines/reference/tsserver/projectReferences/with-disableSolutionSearching-solution-and-siblings-are-not-loaded.js b/tests/baselines/reference/tsserver/projectReferences/with-disableSolutionSearching-solution-and-siblings-are-not-loaded.js index af244659e889f..c979a5b84dd6f 100644 --- a/tests/baselines/reference/tsserver/projectReferences/with-disableSolutionSearching-solution-and-siblings-are-not-loaded.js +++ b/tests/baselines/reference/tsserver/projectReferences/with-disableSolutionSearching-solution-and-siblings-are-not-loaded.js @@ -33,7 +33,7 @@ Project '/user/username/projects/solution/compiler/tsconfig.json' (Configured) ../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' types.ts Part of 'files' list in tsconfig.json program.ts diff --git a/tests/baselines/reference/tsserver/projects/getting-errors-from-closed-script-info-does-not-throw-exception-because-of-getting-project-from-orphan-script-info.js b/tests/baselines/reference/tsserver/projects/getting-errors-from-closed-script-info-does-not-throw-exception-because-of-getting-project-from-orphan-script-info.js index ab3c92b0b9a1d..d80fa072de0c4 100644 --- a/tests/baselines/reference/tsserver/projects/getting-errors-from-closed-script-info-does-not-throw-exception-because-of-getting-project-from-orphan-script-info.js +++ b/tests/baselines/reference/tsserver/projects/getting-errors-from-closed-script-info-does-not-throw-exception-because-of-getting-project-from-orphan-script-info.js @@ -27,7 +27,7 @@ Project '/a/b/tsconfig.json' (Configured) ../lib/lib.d.ts - Default library + Default library for target 'es3' app.ts Matched by include pattern '**/*' in 'tsconfig.json' diff --git a/tests/baselines/reference/tsserver/projects/handles-delayed-directory-watch-invoke-on-file-creation.js b/tests/baselines/reference/tsserver/projects/handles-delayed-directory-watch-invoke-on-file-creation.js index 306fe238706cd..fddcb0fa0e0c3 100644 --- a/tests/baselines/reference/tsserver/projects/handles-delayed-directory-watch-invoke-on-file-creation.js +++ b/tests/baselines/reference/tsserver/projects/handles-delayed-directory-watch-invoke-on-file-creation.js @@ -32,7 +32,7 @@ Project '/users/username/projects/project/tsconfig.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' b.ts Matched by include pattern '**/*' in 'tsconfig.json' sub/a.ts @@ -101,7 +101,7 @@ Project '/users/username/projects/project/tsconfig.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' b.ts Matched by include pattern '**/*' in 'tsconfig.json' a.ts @@ -167,7 +167,7 @@ Project '/users/username/projects/project/tsconfig.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' b.ts Matched by include pattern '**/*' in 'tsconfig.json' @@ -273,7 +273,7 @@ Project '/users/username/projects/project/tsconfig.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' b.ts Matched by include pattern '**/*' in 'tsconfig.json' sub/a.ts diff --git a/tests/baselines/reference/tsserver/symLinks/module-resolution-when-project-compiles-from-sources.js b/tests/baselines/reference/tsserver/symLinks/module-resolution-when-project-compiles-from-sources.js index a77bb2e51b5fe..cb3c63b45f1cb 100644 --- a/tests/baselines/reference/tsserver/symLinks/module-resolution-when-project-compiles-from-sources.js +++ b/tests/baselines/reference/tsserver/symLinks/module-resolution-when-project-compiles-from-sources.js @@ -45,7 +45,7 @@ Project '/users/username/projects/myproject/javascript/packages/recognizers-date ../../../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/datetime/baseDate.ts Matched by include pattern 'src' in 'tsconfig.json' @@ -103,7 +103,7 @@ Project '/users/username/projects/myproject/javascript/packages/recognizers-date ../../../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../recognizers-text/dist/types/recognizers-text.d.ts Imported via "@microsoft/recognizers-text" from file 'src/datetime/baseDate.ts' src/datetime/baseDate.ts diff --git a/tests/baselines/reference/tsserver/symLinks/module-resolution-when-project-has-node_modules-setup-but-doesnt-have-modules-in-typings-folder-and-then-recompiles.js b/tests/baselines/reference/tsserver/symLinks/module-resolution-when-project-has-node_modules-setup-but-doesnt-have-modules-in-typings-folder-and-then-recompiles.js index e34260a45bdb2..73d3cc01ddeed 100644 --- a/tests/baselines/reference/tsserver/symLinks/module-resolution-when-project-has-node_modules-setup-but-doesnt-have-modules-in-typings-folder-and-then-recompiles.js +++ b/tests/baselines/reference/tsserver/symLinks/module-resolution-when-project-has-node_modules-setup-but-doesnt-have-modules-in-typings-folder-and-then-recompiles.js @@ -45,7 +45,7 @@ Project '/users/username/projects/myproject/javascript/packages/recognizers-date ../../../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/datetime/baseDate.ts Matched by include pattern 'src' in 'tsconfig.json' diff --git a/tests/baselines/reference/tsserver/symLinks/module-resolution-when-project-recompiles-after-deleting-generated-folders.js b/tests/baselines/reference/tsserver/symLinks/module-resolution-when-project-recompiles-after-deleting-generated-folders.js index 8358625f4853e..8135d10fc6a27 100644 --- a/tests/baselines/reference/tsserver/symLinks/module-resolution-when-project-recompiles-after-deleting-generated-folders.js +++ b/tests/baselines/reference/tsserver/symLinks/module-resolution-when-project-recompiles-after-deleting-generated-folders.js @@ -41,7 +41,7 @@ Project '/users/username/projects/myproject/javascript/packages/recognizers-date ../../../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../recognizers-text/dist/types/recognizers-text.d.ts Imported via "@microsoft/recognizers-text" from file 'src/datetime/baseDate.ts' src/datetime/baseDate.ts @@ -93,7 +93,7 @@ Project '/users/username/projects/myproject/javascript/packages/recognizers-date ../../../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/datetime/baseDate.ts Matched by include pattern 'src' in 'tsconfig.json' diff --git a/tests/baselines/reference/tsserver/symLinks/module-resolution-with-path-mapping-when-project-compiles-from-sources.js b/tests/baselines/reference/tsserver/symLinks/module-resolution-with-path-mapping-when-project-compiles-from-sources.js index 170cbacc4d17f..d7f9852e16033 100644 --- a/tests/baselines/reference/tsserver/symLinks/module-resolution-with-path-mapping-when-project-compiles-from-sources.js +++ b/tests/baselines/reference/tsserver/symLinks/module-resolution-with-path-mapping-when-project-compiles-from-sources.js @@ -57,7 +57,7 @@ Project '/users/username/projects/myproject/javascript/packages/recognizers-date ../../../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/datetime/baseDate.ts Matched by include pattern 'src' in 'tsconfig.json' @@ -128,7 +128,7 @@ Project '/users/username/projects/myproject/javascript/packages/recognizers-date ../../../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../recognizers-text/dist/types/recognizers-text.d.ts Imported via "@microsoft/recognizers-text" from file 'src/datetime/baseDate.ts' src/datetime/baseDate.ts diff --git a/tests/baselines/reference/tsserver/symLinks/module-resolution-with-path-mapping-when-project-has-node_modules-setup-but-doesnt-have-modules-in-typings-folder-and-then-recompiles.js b/tests/baselines/reference/tsserver/symLinks/module-resolution-with-path-mapping-when-project-has-node_modules-setup-but-doesnt-have-modules-in-typings-folder-and-then-recompiles.js index cd7d0a69f8dfb..c0d72dafd98fb 100644 --- a/tests/baselines/reference/tsserver/symLinks/module-resolution-with-path-mapping-when-project-has-node_modules-setup-but-doesnt-have-modules-in-typings-folder-and-then-recompiles.js +++ b/tests/baselines/reference/tsserver/symLinks/module-resolution-with-path-mapping-when-project-has-node_modules-setup-but-doesnt-have-modules-in-typings-folder-and-then-recompiles.js @@ -57,7 +57,7 @@ Project '/users/username/projects/myproject/javascript/packages/recognizers-date ../../../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/datetime/baseDate.ts Matched by include pattern 'src' in 'tsconfig.json' @@ -120,7 +120,7 @@ Project '/users/username/projects/myproject/javascript/packages/recognizers-date ../../../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../recognizers-text/dist/types/recognizers-text.d.ts Imported via "@microsoft/recognizers-text" from file 'src/datetime/baseDate.ts' src/datetime/baseDate.ts diff --git a/tests/baselines/reference/tsserver/symLinks/module-resolution-with-path-mapping-when-project-recompiles-after-deleting-generated-folders.js b/tests/baselines/reference/tsserver/symLinks/module-resolution-with-path-mapping-when-project-recompiles-after-deleting-generated-folders.js index b170b793afd68..03d1e2e66885c 100644 --- a/tests/baselines/reference/tsserver/symLinks/module-resolution-with-path-mapping-when-project-recompiles-after-deleting-generated-folders.js +++ b/tests/baselines/reference/tsserver/symLinks/module-resolution-with-path-mapping-when-project-recompiles-after-deleting-generated-folders.js @@ -47,7 +47,7 @@ Project '/users/username/projects/myproject/javascript/packages/recognizers-date ../../../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../recognizers-text/dist/types/recognizers-text.d.ts Imported via "@microsoft/recognizers-text" from file 'src/datetime/baseDate.ts' src/datetime/baseDate.ts @@ -105,7 +105,7 @@ Project '/users/username/projects/myproject/javascript/packages/recognizers-date ../../../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' src/datetime/baseDate.ts Matched by include pattern 'src' in 'tsconfig.json' @@ -176,7 +176,7 @@ Project '/users/username/projects/myproject/javascript/packages/recognizers-date ../../../../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' ../recognizers-text/dist/types/recognizers-text.d.ts Imported via "@microsoft/recognizers-text" from file 'src/datetime/baseDate.ts' src/datetime/baseDate.ts diff --git a/tests/baselines/reference/tsserver/symLinks/rename-in-common-file-renames-all-project.js b/tests/baselines/reference/tsserver/symLinks/rename-in-common-file-renames-all-project.js index 4911e8dd31f46..8c65341cf397e 100644 --- a/tests/baselines/reference/tsserver/symLinks/rename-in-common-file-renames-all-project.js +++ b/tests/baselines/reference/tsserver/symLinks/rename-in-common-file-renames-all-project.js @@ -31,7 +31,7 @@ Project '/users/username/projects/a/tsconfig.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' c/fc.ts Imported via "./c/fc" from file 'a.ts' Matched by include pattern '**/*' in 'tsconfig.json' @@ -78,7 +78,7 @@ Project '/users/username/projects/b/tsconfig.json' (Configured) ../../../../a/lib/lib.d.ts - Default library + Default library for target 'es3' c/fc.ts Imported via "./c/fc" from file 'b.ts' Matched by include pattern '**/*' in 'tsconfig.json' diff --git a/tests/cases/conformance/node/nodeModules1.ts b/tests/cases/conformance/node/nodeModules1.ts new file mode 100644 index 0000000000000..9d81258595ae8 --- /dev/null +++ b/tests/cases/conformance/node/nodeModules1.ts @@ -0,0 +1,34 @@ +// @module: node12,nodenext +// @filename: subfolder/index.ts +// cjs format file +const x = 1; +export {x}; +// @filename: subfolder2/index.ts +// cjs format file +const x = 1; +export {x}; +// @filename: subfolder2/another/index.ts +// esm format file +const x = 1; +export {x}; +// @filename: index.ts +// esm format file +const x = 1; +export {x}; +// @filename: package.json +{ + "name": "package", + "private": true, + "type": "module" +} +// @filename: subfolder/package.json +{ + "type": "commonjs" +} +// @filename: subfolder2/package.json +{ +} +// @filename: subfolder2/another/package.json +{ + "type": "module" +} \ No newline at end of file diff --git a/tests/cases/conformance/node/nodeModulesDynamicImport.ts b/tests/cases/conformance/node/nodeModulesDynamicImport.ts new file mode 100644 index 0000000000000..75a5dcfc88cfb --- /dev/null +++ b/tests/cases/conformance/node/nodeModulesDynamicImport.ts @@ -0,0 +1,23 @@ +// @module: node12,nodenext +// @filename: subfolder/index.ts +// cjs format file +export async function main() { + const { readFile } = await import("fs"); +} +// @filename: index.ts +// esm format file +export async function main() { + const { readFile } = await import("fs"); +} +// @filename: package.json +{ + "name": "package", + "private": true, + "type": "module" +} +// @filename: subfolder/package.json +{ + "type": "commonjs" +} +// @filename: types.d.ts +declare module "fs"; \ No newline at end of file diff --git a/tests/cases/conformance/node/nodeModulesExportAssignments.ts b/tests/cases/conformance/node/nodeModulesExportAssignments.ts new file mode 100644 index 0000000000000..ba604d85090ac --- /dev/null +++ b/tests/cases/conformance/node/nodeModulesExportAssignments.ts @@ -0,0 +1,19 @@ +// @module: node12,nodenext +// @filename: subfolder/index.ts +// cjs format file +const a = {}; +export = a; +// @filename: index.ts +// esm format file +const a = {}; +export = a; +// @filename: package.json +{ + "name": "package", + "private": true, + "type": "module" +} +// @filename: subfolder/package.json +{ + "type": "commonjs" +} \ No newline at end of file diff --git a/tests/cases/conformance/node/nodeModulesGeneratedNameCollisions.ts b/tests/cases/conformance/node/nodeModulesGeneratedNameCollisions.ts new file mode 100644 index 0000000000000..5f708e1454c7b --- /dev/null +++ b/tests/cases/conformance/node/nodeModulesGeneratedNameCollisions.ts @@ -0,0 +1,25 @@ +// @module: node12,nodenext +// @filename: subfolder/index.ts +// cjs format file +function require() {} +const exports = {}; +class Object {} +export const __esModule = false; +export {require, exports, Object}; +// @filename: index.ts +// esm format file +function require() {} +const exports = {}; +class Object {} +export const __esModule = false; +export {require, exports, Object}; +// @filename: package.json +{ + "name": "package", + "private": true, + "type": "module" +} +// @filename: subfolder/package.json +{ + "type": "commonjs" +} \ No newline at end of file diff --git a/tests/cases/conformance/node/nodeModulesImportAssignments.ts b/tests/cases/conformance/node/nodeModulesImportAssignments.ts new file mode 100644 index 0000000000000..d89c23438256a --- /dev/null +++ b/tests/cases/conformance/node/nodeModulesImportAssignments.ts @@ -0,0 +1,30 @@ +// @module: node12,nodenext +// @filename: subfolder/index.ts +// cjs format file +import fs = require("fs"); +fs.readFile; +export import fs2 = require("fs"); +// @filename: index.ts +// esm format file +import fs = require("fs"); +fs.readFile; +export import fs2 = require("fs"); +// @filename: file.ts +// esm format file +const __require = null; +const _createRequire = null; +import fs = require("fs"); +fs.readFile; +export import fs2 = require("fs"); +// @filename: package.json +{ + "name": "package", + "private": true, + "type": "module" +} +// @filename: subfolder/package.json +{ + "type": "commonjs" +} +// @filename: types.d.ts +declare module "fs"; \ No newline at end of file diff --git a/tests/cases/conformance/node/nodeModulesImportHelpersCollisions.ts b/tests/cases/conformance/node/nodeModulesImportHelpersCollisions.ts new file mode 100644 index 0000000000000..95f3830e818fa --- /dev/null +++ b/tests/cases/conformance/node/nodeModulesImportHelpersCollisions.ts @@ -0,0 +1,30 @@ +// @module: node12,nodenext +// @importHelpers: true +// @filename: subfolder/index.ts +// cjs format file +import {default as _fs} from "fs"; +_fs.readFile; +import * as fs from "fs"; +fs.readFile; +// @filename: index.ts +// esm format file +import {default as _fs} from "fs"; +_fs.readFile; +import * as fs from "fs"; +fs.readFile; +// @filename: package.json +{ + "name": "package", + "private": true, + "type": "module" +} +// @filename: subfolder/package.json +{ + "type": "commonjs" +} +// @filename: types.d.ts +declare module "fs"; +declare module "tslib" { + export {}; + // intentionally missing all helpers +} \ No newline at end of file diff --git a/tests/cases/conformance/node/nodeModulesImportHelpersCollisions2.ts b/tests/cases/conformance/node/nodeModulesImportHelpersCollisions2.ts new file mode 100644 index 0000000000000..f018d86e63848 --- /dev/null +++ b/tests/cases/conformance/node/nodeModulesImportHelpersCollisions2.ts @@ -0,0 +1,26 @@ +// @module: node12,nodenext +// @importHelpers: true +// @filename: subfolder/index.ts +// cjs format file +export * from "fs"; +export * as fs from "fs"; +// @filename: index.ts +// esm format file +export * from "fs"; +export * as fs from "fs"; +// @filename: package.json +{ + "name": "package", + "private": true, + "type": "module" +} +// @filename: subfolder/package.json +{ + "type": "commonjs" +} +// @filename: types.d.ts +declare module "fs"; +declare module "tslib" { + export {}; + // intentionally missing all helpers +} \ No newline at end of file diff --git a/tests/cases/conformance/node/nodeModulesImportHelpersCollisions3.ts b/tests/cases/conformance/node/nodeModulesImportHelpersCollisions3.ts new file mode 100644 index 0000000000000..b661affe17a2c --- /dev/null +++ b/tests/cases/conformance/node/nodeModulesImportHelpersCollisions3.ts @@ -0,0 +1,24 @@ +// @module: node12,nodenext +// @importHelpers: true +// @filename: subfolder/index.ts +// cjs format file +export {default} from "fs"; +// @filename: index.ts +// esm format file +export {default} from "fs"; +// @filename: package.json +{ + "name": "package", + "private": true, + "type": "module" +} +// @filename: subfolder/package.json +{ + "type": "commonjs" +} +// @filename: types.d.ts +declare module "fs"; +declare module "tslib" { + export {}; + // intentionally missing all helpers +} \ No newline at end of file diff --git a/tests/cases/conformance/node/nodeModulesImportMeta.ts b/tests/cases/conformance/node/nodeModulesImportMeta.ts new file mode 100644 index 0000000000000..ea83d1b33b3b3 --- /dev/null +++ b/tests/cases/conformance/node/nodeModulesImportMeta.ts @@ -0,0 +1,19 @@ +// @module: node12,nodenext +// @filename: subfolder/index.ts +// cjs format file +const x = import.meta.url; +export {x}; +// @filename: index.ts +// esm format file +const x = import.meta.url; +export {x}; +// @filename: package.json +{ + "name": "package", + "private": true, + "type": "module" +} +// @filename: subfolder/package.json +{ + "type": "commonjs" +} \ No newline at end of file diff --git a/tests/cases/conformance/node/nodeModulesSynchronousCallErrors.ts b/tests/cases/conformance/node/nodeModulesSynchronousCallErrors.ts new file mode 100644 index 0000000000000..8505ee4775096 --- /dev/null +++ b/tests/cases/conformance/node/nodeModulesSynchronousCallErrors.ts @@ -0,0 +1,33 @@ +// @module: node12,nodenext +// @filename: subfolder/index.ts +// cjs format file +import {h} from "../index.js"; +import mod = require("../index.js"); +import {f as _f} from "./index.js"; +import mod2 = require("./index.js"); +export async function f() { + const mod3 = await import ("../index.js"); + const mod4 = await import ("./index.js"); + h(); +} +// @filename: index.ts +// esm format file +import {h as _h} from "./index.js"; +import mod = require("./index.js"); +import {f} from "./subfolder/index.js"; +import mod2 = require("./subfolder/index.js"); +export async function h() { + const mod3 = await import ("./index.js"); + const mod4 = await import ("./subfolder/index.js"); + f(); +} +// @filename: package.json +{ + "name": "package", + "private": true, + "type": "module" +} +// @filename: subfolder/package.json +{ + "type": "commonjs" +} \ No newline at end of file diff --git a/tests/cases/conformance/node/nodeModulesTopLevelAwait.ts b/tests/cases/conformance/node/nodeModulesTopLevelAwait.ts new file mode 100644 index 0000000000000..4c950c0072f1d --- /dev/null +++ b/tests/cases/conformance/node/nodeModulesTopLevelAwait.ts @@ -0,0 +1,21 @@ +// @module: node12,nodenext +// @filename: subfolder/index.ts +// cjs format file +const x = await 1; +export {x}; +for await (const y of []) {} +// @filename: index.ts +// esm format file +const x = await 1; +export {x}; +for await (const y of []) {} +// @filename: package.json +{ + "name": "package", + "private": true, + "type": "module" +} +// @filename: subfolder/package.json +{ + "type": "commonjs" +} \ No newline at end of file From 34812f09ba623ed1ee14a779f6da697de2d19e69 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Mon, 7 Jun 2021 21:28:21 -0700 Subject: [PATCH 2/9] Add allowJs and declaration emit enabled tests --- src/compiler/checker.ts | 26 ++++++- .../reference/nodeModules1(module=node12).js | 14 ++++ .../nodeModules1(module=nodenext).js | 14 ++++ .../nodeModulesAllowJs1(module=node12).js | 68 +++++++++++++++++++ ...nodeModulesAllowJs1(module=node12).symbols | 32 +++++++++ .../nodeModulesAllowJs1(module=node12).types | 36 ++++++++++ .../nodeModulesAllowJs1(module=nodenext).js | 68 +++++++++++++++++++ ...deModulesAllowJs1(module=nodenext).symbols | 32 +++++++++ ...nodeModulesAllowJs1(module=nodenext).types | 36 ++++++++++ ...ulesAllowJsDynamicImport(module=node12).js | 45 ++++++++++++ ...llowJsDynamicImport(module=node12).symbols | 22 ++++++ ...sAllowJsDynamicImport(module=node12).types | 26 +++++++ ...esAllowJsDynamicImport(module=nodenext).js | 45 ++++++++++++ ...owJsDynamicImport(module=nodenext).symbols | 22 ++++++ ...llowJsDynamicImport(module=nodenext).types | 26 +++++++ ...ExportAssignment(module=node12).errors.txt | 41 +++++++++++ ...sAllowJsExportAssignment(module=node12).js | 61 +++++++++++++++++ ...wJsExportAssignment(module=node12).symbols | 36 ++++++++++ ...lowJsExportAssignment(module=node12).types | 45 ++++++++++++ ...portAssignment(module=nodenext).errors.txt | 41 +++++++++++ ...llowJsExportAssignment(module=nodenext).js | 61 +++++++++++++++++ ...sExportAssignment(module=nodenext).symbols | 36 ++++++++++ ...wJsExportAssignment(module=nodenext).types | 45 ++++++++++++ ...edNameCollisions(module=node12).errors.txt | 38 +++++++++++ ...sGeneratedNameCollisions(module=node12).js | 62 +++++++++++++++++ ...ratedNameCollisions(module=node12).symbols | 38 +++++++++++ ...neratedNameCollisions(module=node12).types | 42 ++++++++++++ ...NameCollisions(module=nodenext).errors.txt | 38 +++++++++++ ...eneratedNameCollisions(module=nodenext).js | 62 +++++++++++++++++ ...tedNameCollisions(module=nodenext).symbols | 38 +++++++++++ ...ratedNameCollisions(module=nodenext).types | 42 ++++++++++++ ...ImportAssignment(module=node12).errors.txt | 49 +++++++++++++ ...sAllowJsImportAssignment(module=node12).js | 68 +++++++++++++++++++ ...wJsImportAssignment(module=node12).symbols | 43 ++++++++++++ ...lowJsImportAssignment(module=node12).types | 51 ++++++++++++++ ...portAssignment(module=nodenext).errors.txt | 49 +++++++++++++ ...llowJsImportAssignment(module=nodenext).js | 68 +++++++++++++++++++ ...sImportAssignment(module=nodenext).symbols | 43 ++++++++++++ ...wJsImportAssignment(module=nodenext).types | 51 ++++++++++++++ ...lpersCollisions1(module=node12).errors.txt | 36 ++++++++++ ...ImportHelpersCollisions1(module=node12).js | 52 ++++++++++++++ ...tHelpersCollisions1(module=node12).symbols | 40 +++++++++++ ...ortHelpersCollisions1(module=node12).types | 48 +++++++++++++ ...ersCollisions1(module=nodenext).errors.txt | 36 ++++++++++ ...portHelpersCollisions1(module=nodenext).js | 52 ++++++++++++++ ...elpersCollisions1(module=nodenext).symbols | 40 +++++++++++ ...tHelpersCollisions1(module=nodenext).types | 48 +++++++++++++ ...lpersCollisions2(module=node12).errors.txt | 32 +++++++++ ...ImportHelpersCollisions2(module=node12).js | 48 +++++++++++++ ...tHelpersCollisions2(module=node12).symbols | 22 ++++++ ...ortHelpersCollisions2(module=node12).types | 22 ++++++ ...ersCollisions2(module=nodenext).errors.txt | 32 +++++++++ ...portHelpersCollisions2(module=nodenext).js | 48 +++++++++++++ ...elpersCollisions2(module=nodenext).symbols | 22 ++++++ ...tHelpersCollisions2(module=nodenext).types | 22 ++++++ ...lpersCollisions3(module=node12).errors.txt | 31 +++++++++ ...ImportHelpersCollisions3(module=node12).js | 54 +++++++++++++++ ...tHelpersCollisions3(module=node12).symbols | 36 ++++++++++ ...ortHelpersCollisions3(module=node12).types | 36 ++++++++++ ...ersCollisions3(module=nodenext).errors.txt | 31 +++++++++ ...portHelpersCollisions3(module=nodenext).js | 54 +++++++++++++++ ...elpersCollisions3(module=nodenext).symbols | 36 ++++++++++ ...tHelpersCollisions3(module=nodenext).types | 36 ++++++++++ ...llowJsImportMeta(module=node12).errors.txt | 23 +++++++ ...ModulesAllowJsImportMeta(module=node12).js | 38 +++++++++++ ...esAllowJsImportMeta(module=node12).symbols | 20 ++++++ ...ulesAllowJsImportMeta(module=node12).types | 24 +++++++ ...owJsImportMeta(module=nodenext).errors.txt | 23 +++++++ ...dulesAllowJsImportMeta(module=nodenext).js | 38 +++++++++++ ...AllowJsImportMeta(module=nodenext).symbols | 20 ++++++ ...esAllowJsImportMeta(module=nodenext).types | 24 +++++++ ...ronousCallErrors(module=node12).errors.txt | 55 +++++++++++++++ ...wJsSynchronousCallErrors(module=node12).js | 60 ++++++++++++++++ ...nchronousCallErrors(module=node12).symbols | 58 ++++++++++++++++ ...SynchronousCallErrors(module=node12).types | 68 +++++++++++++++++++ ...nousCallErrors(module=nodenext).errors.txt | 55 +++++++++++++++ ...sSynchronousCallErrors(module=nodenext).js | 60 ++++++++++++++++ ...hronousCallErrors(module=nodenext).symbols | 58 ++++++++++++++++ ...nchronousCallErrors(module=nodenext).types | 68 +++++++++++++++++++ ...wJsTopLevelAwait(module=node12).errors.txt | 34 ++++++++++ ...ulesAllowJsTopLevelAwait(module=node12).js | 42 ++++++++++++ ...llowJsTopLevelAwait(module=node12).symbols | 22 ++++++ ...sAllowJsTopLevelAwait(module=node12).types | 28 ++++++++ ...sTopLevelAwait(module=nodenext).errors.txt | 28 ++++++++ ...esAllowJsTopLevelAwait(module=nodenext).js | 42 ++++++++++++ ...owJsTopLevelAwait(module=nodenext).symbols | 22 ++++++ ...llowJsTopLevelAwait(module=nodenext).types | 28 ++++++++ ...nodeModulesDynamicImport(module=node12).js | 6 ++ ...deModulesDynamicImport(module=nodenext).js | 6 ++ ...ModulesExportAssignments(module=node12).js | 8 +++ ...dulesExportAssignments(module=nodenext).js | 8 +++ ...sGeneratedNameCollisions(module=node12).js | 16 +++++ ...eneratedNameCollisions(module=nodenext).js | 16 +++++ ...ModulesImportAssignments(module=node12).js | 8 +++ ...dulesImportAssignments(module=nodenext).js | 8 +++ ...sImportHelpersCollisions(module=node12).js | 6 ++ ...mportHelpersCollisions(module=nodenext).js | 6 ++ ...ImportHelpersCollisions2(module=node12).js | 8 +++ ...portHelpersCollisions2(module=nodenext).js | 8 +++ ...ImportHelpersCollisions3(module=node12).js | 6 ++ ...portHelpersCollisions3(module=nodenext).js | 6 ++ .../nodeModulesImportMeta(module=node12).js | 8 +++ .../nodeModulesImportMeta(module=nodenext).js | 8 +++ ...lesSynchronousCallErrors(module=node12).js | 6 ++ ...sSynchronousCallErrors(module=nodenext).js | 6 ++ ...nodeModulesTopLevelAwait(module=node12).js | 8 +++ ...deModulesTopLevelAwait(module=nodenext).js | 8 +++ .../node/allowJs/nodeModulesAllowJs1.ts | 38 +++++++++++ .../nodeModulesAllowJsDynamicImport.ts | 27 ++++++++ .../nodeModulesAllowJsExportAssignment.ts | 32 +++++++++ ...deModulesAllowJsGeneratedNameCollisions.ts | 29 ++++++++ .../nodeModulesAllowJsImportAssignment.ts | 34 ++++++++++ ...eModulesAllowJsImportHelpersCollisions1.ts | 34 ++++++++++ ...eModulesAllowJsImportHelpersCollisions2.ts | 30 ++++++++ ...eModulesAllowJsImportHelpersCollisions3.ts | 32 +++++++++ .../allowJs/nodeModulesAllowJsImportMeta.ts | 23 +++++++ ...nodeModulesAllowJsSynchronousCallErrors.ts | 37 ++++++++++ .../nodeModulesAllowJsTopLevelAwait.ts | 25 +++++++ tests/cases/conformance/node/nodeModules1.ts | 1 + .../node/nodeModulesDynamicImport.ts | 1 + .../node/nodeModulesExportAssignments.ts | 1 + .../nodeModulesGeneratedNameCollisions.ts | 1 + .../node/nodeModulesImportAssignments.ts | 1 + .../nodeModulesImportHelpersCollisions.ts | 1 + .../nodeModulesImportHelpersCollisions2.ts | 1 + .../nodeModulesImportHelpersCollisions3.ts | 1 + .../conformance/node/nodeModulesImportMeta.ts | 1 + .../node/nodeModulesSynchronousCallErrors.ts | 1 + .../node/nodeModulesTopLevelAwait.ts | 1 + 129 files changed, 4023 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/nodeModulesAllowJs1(module=node12).js create mode 100644 tests/baselines/reference/nodeModulesAllowJs1(module=node12).symbols create mode 100644 tests/baselines/reference/nodeModulesAllowJs1(module=node12).types create mode 100644 tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).js create mode 100644 tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).symbols create mode 100644 tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).types create mode 100644 tests/baselines/reference/nodeModulesAllowJsDynamicImport(module=node12).js create mode 100644 tests/baselines/reference/nodeModulesAllowJsDynamicImport(module=node12).symbols create mode 100644 tests/baselines/reference/nodeModulesAllowJsDynamicImport(module=node12).types create mode 100644 tests/baselines/reference/nodeModulesAllowJsDynamicImport(module=nodenext).js create mode 100644 tests/baselines/reference/nodeModulesAllowJsDynamicImport(module=nodenext).symbols create mode 100644 tests/baselines/reference/nodeModulesAllowJsDynamicImport(module=nodenext).types create mode 100644 tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=node12).errors.txt create mode 100644 tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=node12).js create mode 100644 tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=node12).symbols create mode 100644 tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=node12).types create mode 100644 tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=nodenext).errors.txt create mode 100644 tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=nodenext).js create mode 100644 tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=nodenext).symbols create mode 100644 tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=nodenext).types create mode 100644 tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=node12).errors.txt create mode 100644 tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=node12).js create mode 100644 tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=node12).symbols create mode 100644 tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=node12).types create mode 100644 tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=nodenext).errors.txt create mode 100644 tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=nodenext).js create mode 100644 tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=nodenext).symbols create mode 100644 tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=nodenext).types create mode 100644 tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=node12).errors.txt create mode 100644 tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=node12).js create mode 100644 tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=node12).symbols create mode 100644 tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=node12).types create mode 100644 tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=nodenext).errors.txt create mode 100644 tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=nodenext).js create mode 100644 tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=nodenext).symbols create mode 100644 tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=nodenext).types create mode 100644 tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=node12).errors.txt create mode 100644 tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=node12).js create mode 100644 tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=node12).symbols create mode 100644 tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=node12).types create mode 100644 tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=nodenext).errors.txt create mode 100644 tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=nodenext).js create mode 100644 tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=nodenext).symbols create mode 100644 tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=nodenext).types create mode 100644 tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=node12).errors.txt create mode 100644 tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=node12).js create mode 100644 tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=node12).symbols create mode 100644 tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=node12).types create mode 100644 tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=nodenext).errors.txt create mode 100644 tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=nodenext).js create mode 100644 tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=nodenext).symbols create mode 100644 tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=nodenext).types create mode 100644 tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=node12).errors.txt create mode 100644 tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=node12).js create mode 100644 tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=node12).symbols create mode 100644 tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=node12).types create mode 100644 tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=nodenext).errors.txt create mode 100644 tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=nodenext).js create mode 100644 tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=nodenext).symbols create mode 100644 tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=nodenext).types create mode 100644 tests/baselines/reference/nodeModulesAllowJsImportMeta(module=node12).errors.txt create mode 100644 tests/baselines/reference/nodeModulesAllowJsImportMeta(module=node12).js create mode 100644 tests/baselines/reference/nodeModulesAllowJsImportMeta(module=node12).symbols create mode 100644 tests/baselines/reference/nodeModulesAllowJsImportMeta(module=node12).types create mode 100644 tests/baselines/reference/nodeModulesAllowJsImportMeta(module=nodenext).errors.txt create mode 100644 tests/baselines/reference/nodeModulesAllowJsImportMeta(module=nodenext).js create mode 100644 tests/baselines/reference/nodeModulesAllowJsImportMeta(module=nodenext).symbols create mode 100644 tests/baselines/reference/nodeModulesAllowJsImportMeta(module=nodenext).types create mode 100644 tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=node12).errors.txt create mode 100644 tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=node12).js create mode 100644 tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=node12).symbols create mode 100644 tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=node12).types create mode 100644 tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=nodenext).errors.txt create mode 100644 tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=nodenext).js create mode 100644 tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=nodenext).symbols create mode 100644 tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=nodenext).types create mode 100644 tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=node12).errors.txt create mode 100644 tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=node12).js create mode 100644 tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=node12).symbols create mode 100644 tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=node12).types create mode 100644 tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=nodenext).errors.txt create mode 100644 tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=nodenext).js create mode 100644 tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=nodenext).symbols create mode 100644 tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=nodenext).types create mode 100644 tests/cases/conformance/node/allowJs/nodeModulesAllowJs1.ts create mode 100644 tests/cases/conformance/node/allowJs/nodeModulesAllowJsDynamicImport.ts create mode 100644 tests/cases/conformance/node/allowJs/nodeModulesAllowJsExportAssignment.ts create mode 100644 tests/cases/conformance/node/allowJs/nodeModulesAllowJsGeneratedNameCollisions.ts create mode 100644 tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportAssignment.ts create mode 100644 tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportHelpersCollisions1.ts create mode 100644 tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportHelpersCollisions2.ts create mode 100644 tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportHelpersCollisions3.ts create mode 100644 tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportMeta.ts create mode 100644 tests/cases/conformance/node/allowJs/nodeModulesAllowJsSynchronousCallErrors.ts create mode 100644 tests/cases/conformance/node/allowJs/nodeModulesAllowJsTopLevelAwait.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 9b8cce1ccc148..70196b6da2add 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7142,6 +7142,28 @@ namespace ts { ), symbol.declarations && filter(symbol.declarations, d => isClassDeclaration(d) || isClassExpression(d))[0]), modifierFlags); } + function getSomeTargetNameFromDeclarations(declarations: Declaration[] | undefined) { + return firstDefined(declarations, d => { + if (isImportSpecifier(d) || isExportSpecifier(d)) { + return idText(d.propertyName || d.name); + } + if (isBinaryExpression(d) || isExportAssignment(d)) { + const expression = isExportAssignment(d) ? d.expression : d.right; + if (isPropertyAccessExpression(expression)) { + return idText(expression.name); + } + } + if (isAliasSymbolDeclaration(d)) { + // This is... heuristic, at best. But it's probably better than always printing the name of the shorthand ambient module. + const name = getNameOfDeclaration(d); + if (name && isIdentifier(name)) { + return idText(name); + } + } + return undefined; + }); + } + function serializeAsAlias(symbol: Symbol, localName: string, modifierFlags: ModifierFlags) { // synthesize an alias, eg `export { symbolName as Name }` // need to mark the alias `symbol` points at @@ -7152,7 +7174,9 @@ namespace ts { if (!target) { return; } - let verbatimTargetName = unescapeLeadingUnderscores(target.escapedName); + // If `target` refers to a shorthand module symbol, the name we're trying to pull out isn;t recoverable from the target symbol + // In such a scenario, we must fall back to looking for an alias declaration on `symbol` and pulling the target name from that + let verbatimTargetName = isShorthandAmbientModuleSymbol(target) && getSomeTargetNameFromDeclarations(symbol.declarations) || unescapeLeadingUnderscores(target.escapedName); if (verbatimTargetName === InternalSymbolName.ExportEquals && (getESModuleInterop(compilerOptions) || compilerOptions.allowSyntheticDefaultImports)) { // target refers to an `export=` symbol that was hoisted into a synthetic default - rename here to match verbatimTargetName = InternalSymbolName.Default; diff --git a/tests/baselines/reference/nodeModules1(module=node12).js b/tests/baselines/reference/nodeModules1(module=node12).js index 3742bb13c5f2a..1acae5c9aab3b 100644 --- a/tests/baselines/reference/nodeModules1(module=node12).js +++ b/tests/baselines/reference/nodeModules1(module=node12).js @@ -56,3 +56,17 @@ export { x }; // esm format file const x = 1; export { x }; + + +//// [index.d.ts] +declare const x = 1; +export { x }; +//// [index.d.ts] +declare const x = 1; +export { x }; +//// [index.d.ts] +declare const x = 1; +export { x }; +//// [index.d.ts] +declare const x = 1; +export { x }; diff --git a/tests/baselines/reference/nodeModules1(module=nodenext).js b/tests/baselines/reference/nodeModules1(module=nodenext).js index 3742bb13c5f2a..1acae5c9aab3b 100644 --- a/tests/baselines/reference/nodeModules1(module=nodenext).js +++ b/tests/baselines/reference/nodeModules1(module=nodenext).js @@ -56,3 +56,17 @@ export { x }; // esm format file const x = 1; export { x }; + + +//// [index.d.ts] +declare const x = 1; +export { x }; +//// [index.d.ts] +declare const x = 1; +export { x }; +//// [index.d.ts] +declare const x = 1; +export { x }; +//// [index.d.ts] +declare const x = 1; +export { x }; diff --git a/tests/baselines/reference/nodeModulesAllowJs1(module=node12).js b/tests/baselines/reference/nodeModulesAllowJs1(module=node12).js new file mode 100644 index 0000000000000..358104e5f6a62 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJs1(module=node12).js @@ -0,0 +1,68 @@ +//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJs1.ts] //// + +//// [index.js] +// cjs format file +const x = 1; +export {x}; +//// [index.js] +// cjs format file +const x = 1; +export {x}; +//// [index.js] +// esm format file +const x = 1; +export {x}; +//// [index.js] +// esm format file +const x = 1; +export {x}; +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} +//// [package.json] +{ +} +//// [package.json] +{ + "type": "module" +} + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +// cjs format file +const x = 1; +exports.x = x; +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +// cjs format file +const x = 1; +exports.x = x; +//// [index.js] +// esm format file +const x = 1; +export { x }; +//// [index.js] +// esm format file +const x = 1; +export { x }; + + +//// [index.d.ts] +export const x: 1; +//// [index.d.ts] +export const x: 1; +//// [index.d.ts] +export const x: 1; +//// [index.d.ts] +export const x: 1; diff --git a/tests/baselines/reference/nodeModulesAllowJs1(module=node12).symbols b/tests/baselines/reference/nodeModulesAllowJs1(module=node12).symbols new file mode 100644 index 0000000000000..99bfb2a40ff73 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJs1(module=node12).symbols @@ -0,0 +1,32 @@ +=== tests/cases/conformance/node/allowJs/subfolder/index.js === +// cjs format file +const x = 1; +>x : Symbol(x, Decl(index.js, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.js, 2, 8)) + +=== tests/cases/conformance/node/allowJs/subfolder2/index.js === +// cjs format file +const x = 1; +>x : Symbol(x, Decl(index.js, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.js, 2, 8)) + +=== tests/cases/conformance/node/allowJs/subfolder2/another/index.js === +// esm format file +const x = 1; +>x : Symbol(x, Decl(index.js, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.js, 2, 8)) + +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +const x = 1; +>x : Symbol(x, Decl(index.js, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.js, 2, 8)) + diff --git a/tests/baselines/reference/nodeModulesAllowJs1(module=node12).types b/tests/baselines/reference/nodeModulesAllowJs1(module=node12).types new file mode 100644 index 0000000000000..bb0713313ec99 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJs1(module=node12).types @@ -0,0 +1,36 @@ +=== tests/cases/conformance/node/allowJs/subfolder/index.js === +// cjs format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + +=== tests/cases/conformance/node/allowJs/subfolder2/index.js === +// cjs format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + +=== tests/cases/conformance/node/allowJs/subfolder2/another/index.js === +// esm format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + diff --git a/tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).js b/tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).js new file mode 100644 index 0000000000000..358104e5f6a62 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).js @@ -0,0 +1,68 @@ +//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJs1.ts] //// + +//// [index.js] +// cjs format file +const x = 1; +export {x}; +//// [index.js] +// cjs format file +const x = 1; +export {x}; +//// [index.js] +// esm format file +const x = 1; +export {x}; +//// [index.js] +// esm format file +const x = 1; +export {x}; +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} +//// [package.json] +{ +} +//// [package.json] +{ + "type": "module" +} + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +// cjs format file +const x = 1; +exports.x = x; +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +// cjs format file +const x = 1; +exports.x = x; +//// [index.js] +// esm format file +const x = 1; +export { x }; +//// [index.js] +// esm format file +const x = 1; +export { x }; + + +//// [index.d.ts] +export const x: 1; +//// [index.d.ts] +export const x: 1; +//// [index.d.ts] +export const x: 1; +//// [index.d.ts] +export const x: 1; diff --git a/tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).symbols b/tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).symbols new file mode 100644 index 0000000000000..99bfb2a40ff73 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).symbols @@ -0,0 +1,32 @@ +=== tests/cases/conformance/node/allowJs/subfolder/index.js === +// cjs format file +const x = 1; +>x : Symbol(x, Decl(index.js, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.js, 2, 8)) + +=== tests/cases/conformance/node/allowJs/subfolder2/index.js === +// cjs format file +const x = 1; +>x : Symbol(x, Decl(index.js, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.js, 2, 8)) + +=== tests/cases/conformance/node/allowJs/subfolder2/another/index.js === +// esm format file +const x = 1; +>x : Symbol(x, Decl(index.js, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.js, 2, 8)) + +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +const x = 1; +>x : Symbol(x, Decl(index.js, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.js, 2, 8)) + diff --git a/tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).types b/tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).types new file mode 100644 index 0000000000000..bb0713313ec99 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).types @@ -0,0 +1,36 @@ +=== tests/cases/conformance/node/allowJs/subfolder/index.js === +// cjs format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + +=== tests/cases/conformance/node/allowJs/subfolder2/index.js === +// cjs format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + +=== tests/cases/conformance/node/allowJs/subfolder2/another/index.js === +// esm format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + diff --git a/tests/baselines/reference/nodeModulesAllowJsDynamicImport(module=node12).js b/tests/baselines/reference/nodeModulesAllowJsDynamicImport(module=node12).js new file mode 100644 index 0000000000000..471912e1192d9 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsDynamicImport(module=node12).js @@ -0,0 +1,45 @@ +//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsDynamicImport.ts] //// + +//// [index.js] +// cjs format file +export async function main() { + const { readFile } = await import("fs"); +} +//// [index.js] +// esm format file +export async function main() { + const { readFile } = await import("fs"); +} +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} +//// [types.d.ts] +declare module "fs"; + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.main = void 0; +// cjs format file +async function main() { + const { readFile } = await import("fs"); +} +exports.main = main; +//// [index.js] +// esm format file +export async function main() { + const { readFile } = await import("fs"); +} + + +//// [index.d.ts] +export function main(): Promise; +//// [index.d.ts] +export function main(): Promise; diff --git a/tests/baselines/reference/nodeModulesAllowJsDynamicImport(module=node12).symbols b/tests/baselines/reference/nodeModulesAllowJsDynamicImport(module=node12).symbols new file mode 100644 index 0000000000000..0b0c85a01f192 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsDynamicImport(module=node12).symbols @@ -0,0 +1,22 @@ +=== tests/cases/conformance/node/allowJs/subfolder/index.js === +// cjs format file +export async function main() { +>main : Symbol(main, Decl(index.js, 0, 0)) + + const { readFile } = await import("fs"); +>readFile : Symbol(readFile, Decl(index.js, 2, 11)) +>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0)) +} +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +export async function main() { +>main : Symbol(main, Decl(index.js, 0, 0)) + + const { readFile } = await import("fs"); +>readFile : Symbol(readFile, Decl(index.js, 2, 11)) +>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0)) +} +=== tests/cases/conformance/node/allowJs/types.d.ts === +declare module "fs"; +>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0)) + diff --git a/tests/baselines/reference/nodeModulesAllowJsDynamicImport(module=node12).types b/tests/baselines/reference/nodeModulesAllowJsDynamicImport(module=node12).types new file mode 100644 index 0000000000000..650fcf3a63733 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsDynamicImport(module=node12).types @@ -0,0 +1,26 @@ +=== tests/cases/conformance/node/allowJs/subfolder/index.js === +// cjs format file +export async function main() { +>main : () => Promise + + const { readFile } = await import("fs"); +>readFile : any +>await import("fs") : any +>import("fs") : Promise +>"fs" : "fs" +} +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +export async function main() { +>main : () => Promise + + const { readFile } = await import("fs"); +>readFile : any +>await import("fs") : any +>import("fs") : Promise +>"fs" : "fs" +} +=== tests/cases/conformance/node/allowJs/types.d.ts === +declare module "fs"; +>"fs" : any + diff --git a/tests/baselines/reference/nodeModulesAllowJsDynamicImport(module=nodenext).js b/tests/baselines/reference/nodeModulesAllowJsDynamicImport(module=nodenext).js new file mode 100644 index 0000000000000..471912e1192d9 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsDynamicImport(module=nodenext).js @@ -0,0 +1,45 @@ +//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsDynamicImport.ts] //// + +//// [index.js] +// cjs format file +export async function main() { + const { readFile } = await import("fs"); +} +//// [index.js] +// esm format file +export async function main() { + const { readFile } = await import("fs"); +} +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} +//// [types.d.ts] +declare module "fs"; + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.main = void 0; +// cjs format file +async function main() { + const { readFile } = await import("fs"); +} +exports.main = main; +//// [index.js] +// esm format file +export async function main() { + const { readFile } = await import("fs"); +} + + +//// [index.d.ts] +export function main(): Promise; +//// [index.d.ts] +export function main(): Promise; diff --git a/tests/baselines/reference/nodeModulesAllowJsDynamicImport(module=nodenext).symbols b/tests/baselines/reference/nodeModulesAllowJsDynamicImport(module=nodenext).symbols new file mode 100644 index 0000000000000..0b0c85a01f192 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsDynamicImport(module=nodenext).symbols @@ -0,0 +1,22 @@ +=== tests/cases/conformance/node/allowJs/subfolder/index.js === +// cjs format file +export async function main() { +>main : Symbol(main, Decl(index.js, 0, 0)) + + const { readFile } = await import("fs"); +>readFile : Symbol(readFile, Decl(index.js, 2, 11)) +>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0)) +} +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +export async function main() { +>main : Symbol(main, Decl(index.js, 0, 0)) + + const { readFile } = await import("fs"); +>readFile : Symbol(readFile, Decl(index.js, 2, 11)) +>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0)) +} +=== tests/cases/conformance/node/allowJs/types.d.ts === +declare module "fs"; +>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0)) + diff --git a/tests/baselines/reference/nodeModulesAllowJsDynamicImport(module=nodenext).types b/tests/baselines/reference/nodeModulesAllowJsDynamicImport(module=nodenext).types new file mode 100644 index 0000000000000..650fcf3a63733 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsDynamicImport(module=nodenext).types @@ -0,0 +1,26 @@ +=== tests/cases/conformance/node/allowJs/subfolder/index.js === +// cjs format file +export async function main() { +>main : () => Promise + + const { readFile } = await import("fs"); +>readFile : any +>await import("fs") : any +>import("fs") : Promise +>"fs" : "fs" +} +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +export async function main() { +>main : () => Promise + + const { readFile } = await import("fs"); +>readFile : any +>await import("fs") : any +>import("fs") : Promise +>"fs" : "fs" +} +=== tests/cases/conformance/node/allowJs/types.d.ts === +declare module "fs"; +>"fs" : any + diff --git a/tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=node12).errors.txt b/tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=node12).errors.txt new file mode 100644 index 0000000000000..a0a3d489f44cb --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=node12).errors.txt @@ -0,0 +1,41 @@ +tests/cases/conformance/node/allowJs/file.js(4,1): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. +tests/cases/conformance/node/allowJs/index.js(3,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. +tests/cases/conformance/node/allowJs/index.js(3,1): error TS8003: 'export =' can only be used in TypeScript files. +tests/cases/conformance/node/allowJs/subfolder/index.js(3,1): error TS8003: 'export =' can only be used in TypeScript files. + + +==== tests/cases/conformance/node/allowJs/subfolder/index.js (1 errors) ==== + // cjs format file + const a = {}; + export = a; + ~~~~~~~~~~~ +!!! error TS8003: 'export =' can only be used in TypeScript files. +==== tests/cases/conformance/node/allowJs/subfolder/file.js (0 errors) ==== + // cjs format file + const a = {}; + module.exports = a; +==== tests/cases/conformance/node/allowJs/index.js (2 errors) ==== + // esm format file + const a = {}; + export = a; + ~~~~~~~~~~~ +!!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. + ~~~~~~~~~~~ +!!! error TS8003: 'export =' can only be used in TypeScript files. +==== tests/cases/conformance/node/allowJs/file.js (1 errors) ==== + // esm format file + import "fs"; + const a = {}; + module.exports = a; + ~~~~~~ +!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. +==== tests/cases/conformance/node/allowJs/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module" + } +==== tests/cases/conformance/node/allowJs/subfolder/package.json (0 errors) ==== + { + "type": "commonjs" + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=node12).js b/tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=node12).js new file mode 100644 index 0000000000000..10d6da622e9a4 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=node12).js @@ -0,0 +1,61 @@ +//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsExportAssignment.ts] //// + +//// [index.js] +// cjs format file +const a = {}; +export = a; +//// [file.js] +// cjs format file +const a = {}; +module.exports = a; +//// [index.js] +// esm format file +const a = {}; +export = a; +//// [file.js] +// esm format file +import "fs"; +const a = {}; +module.exports = a; +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} + +//// [index.js] +"use strict"; +// cjs format file +const a = {}; +module.exports = a; +//// [file.js] +// cjs format file +const a = {}; +module.exports = a; +//// [index.js] +// esm format file +const a = {}; +export {}; +//// [file.js] +// esm format file +import "fs"; +const a = {}; +module.exports = a; + + +//// [index.d.ts] +export = a; +declare const a: {}; +//// [file.d.ts] +export = a; +declare const a: {}; +//// [index.d.ts] +export = a; +declare const a: {}; +//// [file.d.ts] +export {}; diff --git a/tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=node12).symbols b/tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=node12).symbols new file mode 100644 index 0000000000000..4e0e3aed1a9a6 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=node12).symbols @@ -0,0 +1,36 @@ +=== tests/cases/conformance/node/allowJs/subfolder/index.js === +// cjs format file +const a = {}; +>a : Symbol(a, Decl(index.js, 1, 5)) + +export = a; +>a : Symbol(a, Decl(index.js, 1, 5)) + +=== tests/cases/conformance/node/allowJs/subfolder/file.js === +// cjs format file +const a = {}; +>a : Symbol(a, Decl(file.js, 1, 5)) + +module.exports = a; +>module.exports : Symbol(module.exports, Decl(file.js, 0, 0)) +>module : Symbol(export=, Decl(file.js, 1, 13)) +>exports : Symbol(export=, Decl(file.js, 1, 13)) +>a : Symbol(a, Decl(file.js, 1, 5)) + +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +const a = {}; +>a : Symbol(a, Decl(index.js, 1, 5)) + +export = a; +>a : Symbol(a, Decl(index.js, 1, 5)) + +=== tests/cases/conformance/node/allowJs/file.js === +// esm format file +import "fs"; +const a = {}; +>a : Symbol(a, Decl(file.js, 2, 5)) + +module.exports = a; +>a : Symbol(a, Decl(file.js, 2, 5)) + diff --git a/tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=node12).types b/tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=node12).types new file mode 100644 index 0000000000000..e6543212f665f --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=node12).types @@ -0,0 +1,45 @@ +=== tests/cases/conformance/node/allowJs/subfolder/index.js === +// cjs format file +const a = {}; +>a : {} +>{} : {} + +export = a; +>a : {} + +=== tests/cases/conformance/node/allowJs/subfolder/file.js === +// cjs format file +const a = {}; +>a : {} +>{} : {} + +module.exports = a; +>module.exports = a : {} +>module.exports : {} +>module : { exports: {}; } +>exports : {} +>a : {} + +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +const a = {}; +>a : {} +>{} : {} + +export = a; +>a : {} + +=== tests/cases/conformance/node/allowJs/file.js === +// esm format file +import "fs"; +const a = {}; +>a : {} +>{} : {} + +module.exports = a; +>module.exports = a : any +>module.exports : any +>module : any +>exports : any +>a : {} + diff --git a/tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=nodenext).errors.txt new file mode 100644 index 0000000000000..a0a3d489f44cb --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=nodenext).errors.txt @@ -0,0 +1,41 @@ +tests/cases/conformance/node/allowJs/file.js(4,1): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. +tests/cases/conformance/node/allowJs/index.js(3,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. +tests/cases/conformance/node/allowJs/index.js(3,1): error TS8003: 'export =' can only be used in TypeScript files. +tests/cases/conformance/node/allowJs/subfolder/index.js(3,1): error TS8003: 'export =' can only be used in TypeScript files. + + +==== tests/cases/conformance/node/allowJs/subfolder/index.js (1 errors) ==== + // cjs format file + const a = {}; + export = a; + ~~~~~~~~~~~ +!!! error TS8003: 'export =' can only be used in TypeScript files. +==== tests/cases/conformance/node/allowJs/subfolder/file.js (0 errors) ==== + // cjs format file + const a = {}; + module.exports = a; +==== tests/cases/conformance/node/allowJs/index.js (2 errors) ==== + // esm format file + const a = {}; + export = a; + ~~~~~~~~~~~ +!!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead. + ~~~~~~~~~~~ +!!! error TS8003: 'export =' can only be used in TypeScript files. +==== tests/cases/conformance/node/allowJs/file.js (1 errors) ==== + // esm format file + import "fs"; + const a = {}; + module.exports = a; + ~~~~~~ +!!! error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. +==== tests/cases/conformance/node/allowJs/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module" + } +==== tests/cases/conformance/node/allowJs/subfolder/package.json (0 errors) ==== + { + "type": "commonjs" + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=nodenext).js b/tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=nodenext).js new file mode 100644 index 0000000000000..10d6da622e9a4 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=nodenext).js @@ -0,0 +1,61 @@ +//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsExportAssignment.ts] //// + +//// [index.js] +// cjs format file +const a = {}; +export = a; +//// [file.js] +// cjs format file +const a = {}; +module.exports = a; +//// [index.js] +// esm format file +const a = {}; +export = a; +//// [file.js] +// esm format file +import "fs"; +const a = {}; +module.exports = a; +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} + +//// [index.js] +"use strict"; +// cjs format file +const a = {}; +module.exports = a; +//// [file.js] +// cjs format file +const a = {}; +module.exports = a; +//// [index.js] +// esm format file +const a = {}; +export {}; +//// [file.js] +// esm format file +import "fs"; +const a = {}; +module.exports = a; + + +//// [index.d.ts] +export = a; +declare const a: {}; +//// [file.d.ts] +export = a; +declare const a: {}; +//// [index.d.ts] +export = a; +declare const a: {}; +//// [file.d.ts] +export {}; diff --git a/tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=nodenext).symbols b/tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=nodenext).symbols new file mode 100644 index 0000000000000..4e0e3aed1a9a6 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=nodenext).symbols @@ -0,0 +1,36 @@ +=== tests/cases/conformance/node/allowJs/subfolder/index.js === +// cjs format file +const a = {}; +>a : Symbol(a, Decl(index.js, 1, 5)) + +export = a; +>a : Symbol(a, Decl(index.js, 1, 5)) + +=== tests/cases/conformance/node/allowJs/subfolder/file.js === +// cjs format file +const a = {}; +>a : Symbol(a, Decl(file.js, 1, 5)) + +module.exports = a; +>module.exports : Symbol(module.exports, Decl(file.js, 0, 0)) +>module : Symbol(export=, Decl(file.js, 1, 13)) +>exports : Symbol(export=, Decl(file.js, 1, 13)) +>a : Symbol(a, Decl(file.js, 1, 5)) + +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +const a = {}; +>a : Symbol(a, Decl(index.js, 1, 5)) + +export = a; +>a : Symbol(a, Decl(index.js, 1, 5)) + +=== tests/cases/conformance/node/allowJs/file.js === +// esm format file +import "fs"; +const a = {}; +>a : Symbol(a, Decl(file.js, 2, 5)) + +module.exports = a; +>a : Symbol(a, Decl(file.js, 2, 5)) + diff --git a/tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=nodenext).types b/tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=nodenext).types new file mode 100644 index 0000000000000..e6543212f665f --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsExportAssignment(module=nodenext).types @@ -0,0 +1,45 @@ +=== tests/cases/conformance/node/allowJs/subfolder/index.js === +// cjs format file +const a = {}; +>a : {} +>{} : {} + +export = a; +>a : {} + +=== tests/cases/conformance/node/allowJs/subfolder/file.js === +// cjs format file +const a = {}; +>a : {} +>{} : {} + +module.exports = a; +>module.exports = a : {} +>module.exports : {} +>module : { exports: {}; } +>exports : {} +>a : {} + +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +const a = {}; +>a : {} +>{} : {} + +export = a; +>a : {} + +=== tests/cases/conformance/node/allowJs/file.js === +// esm format file +import "fs"; +const a = {}; +>a : {} +>{} : {} + +module.exports = a; +>module.exports = a : any +>module.exports : any +>module : any +>exports : any +>a : {} + diff --git a/tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=node12).errors.txt b/tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=node12).errors.txt new file mode 100644 index 0000000000000..84386984bc398 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=node12).errors.txt @@ -0,0 +1,38 @@ +tests/cases/conformance/node/allowJs/subfolder/index.js(2,10): error TS2441: Duplicate identifier 'require'. Compiler reserves name 'require' in top level scope of a module. +tests/cases/conformance/node/allowJs/subfolder/index.js(3,7): error TS2441: Duplicate identifier 'exports'. Compiler reserves name 'exports' in top level scope of a module. +tests/cases/conformance/node/allowJs/subfolder/index.js(4,7): error TS2725: Class name cannot be 'Object' when targeting ES5 with module Node12. +tests/cases/conformance/node/allowJs/subfolder/index.js(5,14): error TS1216: Identifier expected. '__esModule' is reserved as an exported marker when transforming ECMAScript modules. + + +==== tests/cases/conformance/node/allowJs/subfolder/index.js (4 errors) ==== + // cjs format file + function require() {} + ~~~~~~~ +!!! error TS2441: Duplicate identifier 'require'. Compiler reserves name 'require' in top level scope of a module. + const exports = {}; + ~~~~~~~ +!!! error TS2441: Duplicate identifier 'exports'. Compiler reserves name 'exports' in top level scope of a module. + class Object {} + ~~~~~~ +!!! error TS2725: Class name cannot be 'Object' when targeting ES5 with module Node12. + export const __esModule = false; + ~~~~~~~~~~ +!!! error TS1216: Identifier expected. '__esModule' is reserved as an exported marker when transforming ECMAScript modules. + export {require, exports, Object}; +==== tests/cases/conformance/node/allowJs/index.js (0 errors) ==== + // esm format file + function require() {} + const exports = {}; + class Object {} + export const __esModule = false; + export {require, exports, Object}; +==== tests/cases/conformance/node/allowJs/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module" + } +==== tests/cases/conformance/node/allowJs/subfolder/package.json (0 errors) ==== + { + "type": "commonjs" + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=node12).js b/tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=node12).js new file mode 100644 index 0000000000000..3900870c747d2 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=node12).js @@ -0,0 +1,62 @@ +//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsGeneratedNameCollisions.ts] //// + +//// [index.js] +// cjs format file +function require() {} +const exports = {}; +class Object {} +export const __esModule = false; +export {require, exports, Object}; +//// [index.js] +// esm format file +function require() {} +const exports = {}; +class Object {} +export const __esModule = false; +export {require, exports, Object}; +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Object = exports.exports = exports.require = exports.__esModule = void 0; +// cjs format file +function require() { } +exports.require = require; +const exports = {}; +exports.exports = exports; +class Object { +} +exports.Object = Object; +exports.__esModule = false; +//// [index.js] +// esm format file +function require() { } +const exports = {}; +class Object { +} +export const __esModule = false; +export { require, exports, Object }; + + +//// [index.d.ts] +export const __esModule: false; +export function require(): void; +export const exports: {}; +export class Object { +} +//// [index.d.ts] +export const __esModule: false; +export function require(): void; +export const exports: {}; +export class Object { +} diff --git a/tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=node12).symbols b/tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=node12).symbols new file mode 100644 index 0000000000000..8565d39212c8c --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=node12).symbols @@ -0,0 +1,38 @@ +=== tests/cases/conformance/node/allowJs/subfolder/index.js === +// cjs format file +function require() {} +>require : Symbol(require, Decl(index.js, 0, 0)) + +const exports = {}; +>exports : Symbol(exports, Decl(index.js, 2, 5)) + +class Object {} +>Object : Symbol(Object, Decl(index.js, 2, 19)) + +export const __esModule = false; +>__esModule : Symbol(__esModule, Decl(index.js, 4, 12)) + +export {require, exports, Object}; +>require : Symbol(require, Decl(index.js, 5, 8)) +>exports : Symbol(exports, Decl(index.js, 5, 16)) +>Object : Symbol(Object, Decl(index.js, 5, 25)) + +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +function require() {} +>require : Symbol(require, Decl(index.js, 0, 0)) + +const exports = {}; +>exports : Symbol(exports, Decl(index.js, 2, 5)) + +class Object {} +>Object : Symbol(Object, Decl(index.js, 2, 19)) + +export const __esModule = false; +>__esModule : Symbol(__esModule, Decl(index.js, 4, 12)) + +export {require, exports, Object}; +>require : Symbol(require, Decl(index.js, 5, 8)) +>exports : Symbol(exports, Decl(index.js, 5, 16)) +>Object : Symbol(Object, Decl(index.js, 5, 25)) + diff --git a/tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=node12).types b/tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=node12).types new file mode 100644 index 0000000000000..a290eb3ca58e3 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=node12).types @@ -0,0 +1,42 @@ +=== tests/cases/conformance/node/allowJs/subfolder/index.js === +// cjs format file +function require() {} +>require : () => void + +const exports = {}; +>exports : {} +>{} : {} + +class Object {} +>Object : Object + +export const __esModule = false; +>__esModule : false +>false : false + +export {require, exports, Object}; +>require : () => void +>exports : {} +>Object : typeof Object + +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +function require() {} +>require : () => void + +const exports = {}; +>exports : {} +>{} : {} + +class Object {} +>Object : Object + +export const __esModule = false; +>__esModule : false +>false : false + +export {require, exports, Object}; +>require : () => void +>exports : {} +>Object : typeof Object + diff --git a/tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=nodenext).errors.txt new file mode 100644 index 0000000000000..1e12bbbe4ed99 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=nodenext).errors.txt @@ -0,0 +1,38 @@ +tests/cases/conformance/node/allowJs/subfolder/index.js(2,10): error TS2441: Duplicate identifier 'require'. Compiler reserves name 'require' in top level scope of a module. +tests/cases/conformance/node/allowJs/subfolder/index.js(3,7): error TS2441: Duplicate identifier 'exports'. Compiler reserves name 'exports' in top level scope of a module. +tests/cases/conformance/node/allowJs/subfolder/index.js(4,7): error TS2725: Class name cannot be 'Object' when targeting ES5 with module NodeNext. +tests/cases/conformance/node/allowJs/subfolder/index.js(5,14): error TS1216: Identifier expected. '__esModule' is reserved as an exported marker when transforming ECMAScript modules. + + +==== tests/cases/conformance/node/allowJs/subfolder/index.js (4 errors) ==== + // cjs format file + function require() {} + ~~~~~~~ +!!! error TS2441: Duplicate identifier 'require'. Compiler reserves name 'require' in top level scope of a module. + const exports = {}; + ~~~~~~~ +!!! error TS2441: Duplicate identifier 'exports'. Compiler reserves name 'exports' in top level scope of a module. + class Object {} + ~~~~~~ +!!! error TS2725: Class name cannot be 'Object' when targeting ES5 with module NodeNext. + export const __esModule = false; + ~~~~~~~~~~ +!!! error TS1216: Identifier expected. '__esModule' is reserved as an exported marker when transforming ECMAScript modules. + export {require, exports, Object}; +==== tests/cases/conformance/node/allowJs/index.js (0 errors) ==== + // esm format file + function require() {} + const exports = {}; + class Object {} + export const __esModule = false; + export {require, exports, Object}; +==== tests/cases/conformance/node/allowJs/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module" + } +==== tests/cases/conformance/node/allowJs/subfolder/package.json (0 errors) ==== + { + "type": "commonjs" + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=nodenext).js b/tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=nodenext).js new file mode 100644 index 0000000000000..3900870c747d2 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=nodenext).js @@ -0,0 +1,62 @@ +//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsGeneratedNameCollisions.ts] //// + +//// [index.js] +// cjs format file +function require() {} +const exports = {}; +class Object {} +export const __esModule = false; +export {require, exports, Object}; +//// [index.js] +// esm format file +function require() {} +const exports = {}; +class Object {} +export const __esModule = false; +export {require, exports, Object}; +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Object = exports.exports = exports.require = exports.__esModule = void 0; +// cjs format file +function require() { } +exports.require = require; +const exports = {}; +exports.exports = exports; +class Object { +} +exports.Object = Object; +exports.__esModule = false; +//// [index.js] +// esm format file +function require() { } +const exports = {}; +class Object { +} +export const __esModule = false; +export { require, exports, Object }; + + +//// [index.d.ts] +export const __esModule: false; +export function require(): void; +export const exports: {}; +export class Object { +} +//// [index.d.ts] +export const __esModule: false; +export function require(): void; +export const exports: {}; +export class Object { +} diff --git a/tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=nodenext).symbols b/tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=nodenext).symbols new file mode 100644 index 0000000000000..8565d39212c8c --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=nodenext).symbols @@ -0,0 +1,38 @@ +=== tests/cases/conformance/node/allowJs/subfolder/index.js === +// cjs format file +function require() {} +>require : Symbol(require, Decl(index.js, 0, 0)) + +const exports = {}; +>exports : Symbol(exports, Decl(index.js, 2, 5)) + +class Object {} +>Object : Symbol(Object, Decl(index.js, 2, 19)) + +export const __esModule = false; +>__esModule : Symbol(__esModule, Decl(index.js, 4, 12)) + +export {require, exports, Object}; +>require : Symbol(require, Decl(index.js, 5, 8)) +>exports : Symbol(exports, Decl(index.js, 5, 16)) +>Object : Symbol(Object, Decl(index.js, 5, 25)) + +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +function require() {} +>require : Symbol(require, Decl(index.js, 0, 0)) + +const exports = {}; +>exports : Symbol(exports, Decl(index.js, 2, 5)) + +class Object {} +>Object : Symbol(Object, Decl(index.js, 2, 19)) + +export const __esModule = false; +>__esModule : Symbol(__esModule, Decl(index.js, 4, 12)) + +export {require, exports, Object}; +>require : Symbol(require, Decl(index.js, 5, 8)) +>exports : Symbol(exports, Decl(index.js, 5, 16)) +>Object : Symbol(Object, Decl(index.js, 5, 25)) + diff --git a/tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=nodenext).types b/tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=nodenext).types new file mode 100644 index 0000000000000..a290eb3ca58e3 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsGeneratedNameCollisions(module=nodenext).types @@ -0,0 +1,42 @@ +=== tests/cases/conformance/node/allowJs/subfolder/index.js === +// cjs format file +function require() {} +>require : () => void + +const exports = {}; +>exports : {} +>{} : {} + +class Object {} +>Object : Object + +export const __esModule = false; +>__esModule : false +>false : false + +export {require, exports, Object}; +>require : () => void +>exports : {} +>Object : typeof Object + +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +function require() {} +>require : () => void + +const exports = {}; +>exports : {} +>{} : {} + +class Object {} +>Object : Object + +export const __esModule = false; +>__esModule : false +>false : false + +export {require, exports, Object}; +>require : () => void +>exports : {} +>Object : typeof Object + diff --git a/tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=node12).errors.txt b/tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=node12).errors.txt new file mode 100644 index 0000000000000..bbc352d7a78d5 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=node12).errors.txt @@ -0,0 +1,49 @@ +tests/cases/conformance/node/allowJs/file.js(4,1): error TS8002: 'import ... =' can only be used in TypeScript files. +tests/cases/conformance/node/allowJs/file.js(6,1): error TS8002: 'import ... =' can only be used in TypeScript files. +tests/cases/conformance/node/allowJs/index.js(2,1): error TS8002: 'import ... =' can only be used in TypeScript files. +tests/cases/conformance/node/allowJs/index.js(4,1): error TS8002: 'import ... =' can only be used in TypeScript files. +tests/cases/conformance/node/allowJs/subfolder/index.js(2,1): error TS8002: 'import ... =' can only be used in TypeScript files. +tests/cases/conformance/node/allowJs/subfolder/index.js(4,1): error TS8002: 'import ... =' can only be used in TypeScript files. + + +==== tests/cases/conformance/node/allowJs/subfolder/index.js (2 errors) ==== + // cjs format file + import fs = require("fs"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + fs.readFile; + export import fs2 = require("fs"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. +==== tests/cases/conformance/node/allowJs/index.js (2 errors) ==== + // esm format file + import fs = require("fs"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + fs.readFile; + export import fs2 = require("fs"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. +==== tests/cases/conformance/node/allowJs/file.js (2 errors) ==== + // esm format file + const __require = null; + const _createRequire = null; + import fs = require("fs"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + fs.readFile; + export import fs2 = require("fs"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. +==== tests/cases/conformance/node/allowJs/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module" + } +==== tests/cases/conformance/node/allowJs/subfolder/package.json (0 errors) ==== + { + "type": "commonjs" + } +==== tests/cases/conformance/node/allowJs/types.d.ts (0 errors) ==== + declare module "fs"; \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=node12).js b/tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=node12).js new file mode 100644 index 0000000000000..1e97293cca863 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=node12).js @@ -0,0 +1,68 @@ +//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportAssignment.ts] //// + +//// [index.js] +// cjs format file +import fs = require("fs"); +fs.readFile; +export import fs2 = require("fs"); +//// [index.js] +// esm format file +import fs = require("fs"); +fs.readFile; +export import fs2 = require("fs"); +//// [file.js] +// esm format file +const __require = null; +const _createRequire = null; +import fs = require("fs"); +fs.readFile; +export import fs2 = require("fs"); +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} +//// [types.d.ts] +declare module "fs"; + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +// cjs format file +const fs = require("fs"); +fs.readFile; +exports.fs2 = require("fs"); +//// [index.js] +import { createRequire as _createRequire } from "module"; +const __require = _createRequire(import.meta.url); +// esm format file +const fs = __require("fs"); +fs.readFile; +const fs2 = __require("fs"); +export { fs2 }; +//// [file.js] +import { createRequire as _createRequire_1 } from "module"; +const __require_1 = _createRequire_1(import.meta.url); +// esm format file +const __require = null; +const _createRequire = null; +const fs = __require_1("fs"); +fs.readFile; +const fs2 = __require_1("fs"); +export { fs2 }; + + +//// [index.d.ts] +/// +import fs2 = require("fs"); +//// [index.d.ts] +/// +import fs2 = require("fs"); +//// [file.d.ts] +/// +import fs2 = require("fs"); diff --git a/tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=node12).symbols b/tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=node12).symbols new file mode 100644 index 0000000000000..11b3047ebcd76 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=node12).symbols @@ -0,0 +1,43 @@ +=== tests/cases/conformance/node/allowJs/subfolder/index.js === +// cjs format file +import fs = require("fs"); +>fs : Symbol(fs, Decl(index.js, 0, 0)) + +fs.readFile; +>fs : Symbol(fs, Decl(index.js, 0, 0)) + +export import fs2 = require("fs"); +>fs2 : Symbol(fs2, Decl(index.js, 2, 12)) + +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +import fs = require("fs"); +>fs : Symbol(fs, Decl(index.js, 0, 0)) + +fs.readFile; +>fs : Symbol(fs, Decl(index.js, 0, 0)) + +export import fs2 = require("fs"); +>fs2 : Symbol(fs2, Decl(index.js, 2, 12)) + +=== tests/cases/conformance/node/allowJs/file.js === +// esm format file +const __require = null; +>__require : Symbol(__require, Decl(file.js, 1, 5)) + +const _createRequire = null; +>_createRequire : Symbol(_createRequire, Decl(file.js, 2, 5)) + +import fs = require("fs"); +>fs : Symbol(fs, Decl(file.js, 2, 28)) + +fs.readFile; +>fs : Symbol(fs, Decl(file.js, 2, 28)) + +export import fs2 = require("fs"); +>fs2 : Symbol(fs2, Decl(file.js, 4, 12)) + +=== tests/cases/conformance/node/allowJs/types.d.ts === +declare module "fs"; +>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0)) + diff --git a/tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=node12).types b/tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=node12).types new file mode 100644 index 0000000000000..2720b1f1b7dc3 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=node12).types @@ -0,0 +1,51 @@ +=== tests/cases/conformance/node/allowJs/subfolder/index.js === +// cjs format file +import fs = require("fs"); +>fs : any + +fs.readFile; +>fs.readFile : any +>fs : any +>readFile : any + +export import fs2 = require("fs"); +>fs2 : any + +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +import fs = require("fs"); +>fs : any + +fs.readFile; +>fs.readFile : any +>fs : any +>readFile : any + +export import fs2 = require("fs"); +>fs2 : any + +=== tests/cases/conformance/node/allowJs/file.js === +// esm format file +const __require = null; +>__require : any +>null : null + +const _createRequire = null; +>_createRequire : any +>null : null + +import fs = require("fs"); +>fs : any + +fs.readFile; +>fs.readFile : any +>fs : any +>readFile : any + +export import fs2 = require("fs"); +>fs2 : any + +=== tests/cases/conformance/node/allowJs/types.d.ts === +declare module "fs"; +>"fs" : any + diff --git a/tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=nodenext).errors.txt new file mode 100644 index 0000000000000..bbc352d7a78d5 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=nodenext).errors.txt @@ -0,0 +1,49 @@ +tests/cases/conformance/node/allowJs/file.js(4,1): error TS8002: 'import ... =' can only be used in TypeScript files. +tests/cases/conformance/node/allowJs/file.js(6,1): error TS8002: 'import ... =' can only be used in TypeScript files. +tests/cases/conformance/node/allowJs/index.js(2,1): error TS8002: 'import ... =' can only be used in TypeScript files. +tests/cases/conformance/node/allowJs/index.js(4,1): error TS8002: 'import ... =' can only be used in TypeScript files. +tests/cases/conformance/node/allowJs/subfolder/index.js(2,1): error TS8002: 'import ... =' can only be used in TypeScript files. +tests/cases/conformance/node/allowJs/subfolder/index.js(4,1): error TS8002: 'import ... =' can only be used in TypeScript files. + + +==== tests/cases/conformance/node/allowJs/subfolder/index.js (2 errors) ==== + // cjs format file + import fs = require("fs"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + fs.readFile; + export import fs2 = require("fs"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. +==== tests/cases/conformance/node/allowJs/index.js (2 errors) ==== + // esm format file + import fs = require("fs"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + fs.readFile; + export import fs2 = require("fs"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. +==== tests/cases/conformance/node/allowJs/file.js (2 errors) ==== + // esm format file + const __require = null; + const _createRequire = null; + import fs = require("fs"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + fs.readFile; + export import fs2 = require("fs"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. +==== tests/cases/conformance/node/allowJs/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module" + } +==== tests/cases/conformance/node/allowJs/subfolder/package.json (0 errors) ==== + { + "type": "commonjs" + } +==== tests/cases/conformance/node/allowJs/types.d.ts (0 errors) ==== + declare module "fs"; \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=nodenext).js b/tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=nodenext).js new file mode 100644 index 0000000000000..1e97293cca863 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=nodenext).js @@ -0,0 +1,68 @@ +//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportAssignment.ts] //// + +//// [index.js] +// cjs format file +import fs = require("fs"); +fs.readFile; +export import fs2 = require("fs"); +//// [index.js] +// esm format file +import fs = require("fs"); +fs.readFile; +export import fs2 = require("fs"); +//// [file.js] +// esm format file +const __require = null; +const _createRequire = null; +import fs = require("fs"); +fs.readFile; +export import fs2 = require("fs"); +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} +//// [types.d.ts] +declare module "fs"; + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +// cjs format file +const fs = require("fs"); +fs.readFile; +exports.fs2 = require("fs"); +//// [index.js] +import { createRequire as _createRequire } from "module"; +const __require = _createRequire(import.meta.url); +// esm format file +const fs = __require("fs"); +fs.readFile; +const fs2 = __require("fs"); +export { fs2 }; +//// [file.js] +import { createRequire as _createRequire_1 } from "module"; +const __require_1 = _createRequire_1(import.meta.url); +// esm format file +const __require = null; +const _createRequire = null; +const fs = __require_1("fs"); +fs.readFile; +const fs2 = __require_1("fs"); +export { fs2 }; + + +//// [index.d.ts] +/// +import fs2 = require("fs"); +//// [index.d.ts] +/// +import fs2 = require("fs"); +//// [file.d.ts] +/// +import fs2 = require("fs"); diff --git a/tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=nodenext).symbols b/tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=nodenext).symbols new file mode 100644 index 0000000000000..11b3047ebcd76 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=nodenext).symbols @@ -0,0 +1,43 @@ +=== tests/cases/conformance/node/allowJs/subfolder/index.js === +// cjs format file +import fs = require("fs"); +>fs : Symbol(fs, Decl(index.js, 0, 0)) + +fs.readFile; +>fs : Symbol(fs, Decl(index.js, 0, 0)) + +export import fs2 = require("fs"); +>fs2 : Symbol(fs2, Decl(index.js, 2, 12)) + +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +import fs = require("fs"); +>fs : Symbol(fs, Decl(index.js, 0, 0)) + +fs.readFile; +>fs : Symbol(fs, Decl(index.js, 0, 0)) + +export import fs2 = require("fs"); +>fs2 : Symbol(fs2, Decl(index.js, 2, 12)) + +=== tests/cases/conformance/node/allowJs/file.js === +// esm format file +const __require = null; +>__require : Symbol(__require, Decl(file.js, 1, 5)) + +const _createRequire = null; +>_createRequire : Symbol(_createRequire, Decl(file.js, 2, 5)) + +import fs = require("fs"); +>fs : Symbol(fs, Decl(file.js, 2, 28)) + +fs.readFile; +>fs : Symbol(fs, Decl(file.js, 2, 28)) + +export import fs2 = require("fs"); +>fs2 : Symbol(fs2, Decl(file.js, 4, 12)) + +=== tests/cases/conformance/node/allowJs/types.d.ts === +declare module "fs"; +>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0)) + diff --git a/tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=nodenext).types b/tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=nodenext).types new file mode 100644 index 0000000000000..2720b1f1b7dc3 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsImportAssignment(module=nodenext).types @@ -0,0 +1,51 @@ +=== tests/cases/conformance/node/allowJs/subfolder/index.js === +// cjs format file +import fs = require("fs"); +>fs : any + +fs.readFile; +>fs.readFile : any +>fs : any +>readFile : any + +export import fs2 = require("fs"); +>fs2 : any + +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +import fs = require("fs"); +>fs : any + +fs.readFile; +>fs.readFile : any +>fs : any +>readFile : any + +export import fs2 = require("fs"); +>fs2 : any + +=== tests/cases/conformance/node/allowJs/file.js === +// esm format file +const __require = null; +>__require : any +>null : null + +const _createRequire = null; +>_createRequire : any +>null : null + +import fs = require("fs"); +>fs : any + +fs.readFile; +>fs.readFile : any +>fs : any +>readFile : any + +export import fs2 = require("fs"); +>fs2 : any + +=== tests/cases/conformance/node/allowJs/types.d.ts === +declare module "fs"; +>"fs" : any + diff --git a/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=node12).errors.txt b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=node12).errors.txt new file mode 100644 index 0000000000000..b75c1c1e6f563 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=node12).errors.txt @@ -0,0 +1,36 @@ +tests/cases/conformance/node/allowJs/subfolder/index.js(2,9): error TS2343: This syntax requires an imported helper named '__importDefault' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. +tests/cases/conformance/node/allowJs/subfolder/index.js(4,1): error TS2343: This syntax requires an imported helper named '__importStar' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. + + +==== tests/cases/conformance/node/allowJs/subfolder/index.js (2 errors) ==== + // cjs format file + import {default as _fs} from "fs"; + ~~~~~~~~~~~~~~ +!!! error TS2343: This syntax requires an imported helper named '__importDefault' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. + _fs.readFile; + import * as fs from "fs"; + ~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2343: This syntax requires an imported helper named '__importStar' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. + fs.readFile; +==== tests/cases/conformance/node/allowJs/index.js (0 errors) ==== + // esm format file + import {default as _fs} from "fs"; + _fs.readFile; + import * as fs from "fs"; + fs.readFile; +==== tests/cases/conformance/node/allowJs/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module" + } +==== tests/cases/conformance/node/allowJs/subfolder/package.json (0 errors) ==== + { + "type": "commonjs" + } +==== tests/cases/conformance/node/allowJs/types.d.ts (0 errors) ==== + declare module "fs"; + declare module "tslib" { + export {}; + // intentionally missing all helpers + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=node12).js b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=node12).js new file mode 100644 index 0000000000000..4001d6f471cf5 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=node12).js @@ -0,0 +1,52 @@ +//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportHelpersCollisions1.ts] //// + +//// [index.js] +// cjs format file +import {default as _fs} from "fs"; +_fs.readFile; +import * as fs from "fs"; +fs.readFile; +//// [index.js] +// esm format file +import {default as _fs} from "fs"; +_fs.readFile; +import * as fs from "fs"; +fs.readFile; +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} +//// [types.d.ts] +declare module "fs"; +declare module "tslib" { + export {}; + // intentionally missing all helpers +} + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const tslib_1 = require("tslib"); +// cjs format file +const fs_1 = (0, tslib_1.__importDefault)(require("fs")); +fs_1.default.readFile; +const fs = (0, tslib_1.__importStar)(require("fs")); +fs.readFile; +//// [index.js] +// esm format file +import { default as _fs } from "fs"; +_fs.readFile; +import * as fs from "fs"; +fs.readFile; + + +//// [index.d.ts] +export {}; +//// [index.d.ts] +export {}; diff --git a/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=node12).symbols b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=node12).symbols new file mode 100644 index 0000000000000..3822c3fa16d4c --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=node12).symbols @@ -0,0 +1,40 @@ +=== tests/cases/conformance/node/allowJs/subfolder/index.js === +// cjs format file +import {default as _fs} from "fs"; +>default : Symbol(_fs, Decl(types.d.ts, 0, 0)) +>_fs : Symbol(_fs, Decl(index.js, 1, 8)) + +_fs.readFile; +>_fs : Symbol(_fs, Decl(index.js, 1, 8)) + +import * as fs from "fs"; +>fs : Symbol(fs, Decl(index.js, 3, 6)) + +fs.readFile; +>fs : Symbol(fs, Decl(index.js, 3, 6)) + +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +import {default as _fs} from "fs"; +>default : Symbol(_fs, Decl(types.d.ts, 0, 0)) +>_fs : Symbol(_fs, Decl(index.js, 1, 8)) + +_fs.readFile; +>_fs : Symbol(_fs, Decl(index.js, 1, 8)) + +import * as fs from "fs"; +>fs : Symbol(fs, Decl(index.js, 3, 6)) + +fs.readFile; +>fs : Symbol(fs, Decl(index.js, 3, 6)) + +=== tests/cases/conformance/node/allowJs/types.d.ts === +declare module "fs"; +>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0)) + +declare module "tslib" { +>"tslib" : Symbol("tslib", Decl(types.d.ts, 0, 20)) + + export {}; + // intentionally missing all helpers +} diff --git a/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=node12).types b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=node12).types new file mode 100644 index 0000000000000..0b27106eae059 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=node12).types @@ -0,0 +1,48 @@ +=== tests/cases/conformance/node/allowJs/subfolder/index.js === +// cjs format file +import {default as _fs} from "fs"; +>default : any +>_fs : any + +_fs.readFile; +>_fs.readFile : any +>_fs : any +>readFile : any + +import * as fs from "fs"; +>fs : any + +fs.readFile; +>fs.readFile : any +>fs : any +>readFile : any + +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +import {default as _fs} from "fs"; +>default : any +>_fs : any + +_fs.readFile; +>_fs.readFile : any +>_fs : any +>readFile : any + +import * as fs from "fs"; +>fs : any + +fs.readFile; +>fs.readFile : any +>fs : any +>readFile : any + +=== tests/cases/conformance/node/allowJs/types.d.ts === +declare module "fs"; +>"fs" : any + +declare module "tslib" { +>"tslib" : typeof import("tslib") + + export {}; + // intentionally missing all helpers +} diff --git a/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=nodenext).errors.txt new file mode 100644 index 0000000000000..b75c1c1e6f563 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=nodenext).errors.txt @@ -0,0 +1,36 @@ +tests/cases/conformance/node/allowJs/subfolder/index.js(2,9): error TS2343: This syntax requires an imported helper named '__importDefault' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. +tests/cases/conformance/node/allowJs/subfolder/index.js(4,1): error TS2343: This syntax requires an imported helper named '__importStar' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. + + +==== tests/cases/conformance/node/allowJs/subfolder/index.js (2 errors) ==== + // cjs format file + import {default as _fs} from "fs"; + ~~~~~~~~~~~~~~ +!!! error TS2343: This syntax requires an imported helper named '__importDefault' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. + _fs.readFile; + import * as fs from "fs"; + ~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2343: This syntax requires an imported helper named '__importStar' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. + fs.readFile; +==== tests/cases/conformance/node/allowJs/index.js (0 errors) ==== + // esm format file + import {default as _fs} from "fs"; + _fs.readFile; + import * as fs from "fs"; + fs.readFile; +==== tests/cases/conformance/node/allowJs/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module" + } +==== tests/cases/conformance/node/allowJs/subfolder/package.json (0 errors) ==== + { + "type": "commonjs" + } +==== tests/cases/conformance/node/allowJs/types.d.ts (0 errors) ==== + declare module "fs"; + declare module "tslib" { + export {}; + // intentionally missing all helpers + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=nodenext).js b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=nodenext).js new file mode 100644 index 0000000000000..4001d6f471cf5 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=nodenext).js @@ -0,0 +1,52 @@ +//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportHelpersCollisions1.ts] //// + +//// [index.js] +// cjs format file +import {default as _fs} from "fs"; +_fs.readFile; +import * as fs from "fs"; +fs.readFile; +//// [index.js] +// esm format file +import {default as _fs} from "fs"; +_fs.readFile; +import * as fs from "fs"; +fs.readFile; +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} +//// [types.d.ts] +declare module "fs"; +declare module "tslib" { + export {}; + // intentionally missing all helpers +} + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const tslib_1 = require("tslib"); +// cjs format file +const fs_1 = (0, tslib_1.__importDefault)(require("fs")); +fs_1.default.readFile; +const fs = (0, tslib_1.__importStar)(require("fs")); +fs.readFile; +//// [index.js] +// esm format file +import { default as _fs } from "fs"; +_fs.readFile; +import * as fs from "fs"; +fs.readFile; + + +//// [index.d.ts] +export {}; +//// [index.d.ts] +export {}; diff --git a/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=nodenext).symbols b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=nodenext).symbols new file mode 100644 index 0000000000000..3822c3fa16d4c --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=nodenext).symbols @@ -0,0 +1,40 @@ +=== tests/cases/conformance/node/allowJs/subfolder/index.js === +// cjs format file +import {default as _fs} from "fs"; +>default : Symbol(_fs, Decl(types.d.ts, 0, 0)) +>_fs : Symbol(_fs, Decl(index.js, 1, 8)) + +_fs.readFile; +>_fs : Symbol(_fs, Decl(index.js, 1, 8)) + +import * as fs from "fs"; +>fs : Symbol(fs, Decl(index.js, 3, 6)) + +fs.readFile; +>fs : Symbol(fs, Decl(index.js, 3, 6)) + +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +import {default as _fs} from "fs"; +>default : Symbol(_fs, Decl(types.d.ts, 0, 0)) +>_fs : Symbol(_fs, Decl(index.js, 1, 8)) + +_fs.readFile; +>_fs : Symbol(_fs, Decl(index.js, 1, 8)) + +import * as fs from "fs"; +>fs : Symbol(fs, Decl(index.js, 3, 6)) + +fs.readFile; +>fs : Symbol(fs, Decl(index.js, 3, 6)) + +=== tests/cases/conformance/node/allowJs/types.d.ts === +declare module "fs"; +>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0)) + +declare module "tslib" { +>"tslib" : Symbol("tslib", Decl(types.d.ts, 0, 20)) + + export {}; + // intentionally missing all helpers +} diff --git a/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=nodenext).types b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=nodenext).types new file mode 100644 index 0000000000000..0b27106eae059 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions1(module=nodenext).types @@ -0,0 +1,48 @@ +=== tests/cases/conformance/node/allowJs/subfolder/index.js === +// cjs format file +import {default as _fs} from "fs"; +>default : any +>_fs : any + +_fs.readFile; +>_fs.readFile : any +>_fs : any +>readFile : any + +import * as fs from "fs"; +>fs : any + +fs.readFile; +>fs.readFile : any +>fs : any +>readFile : any + +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +import {default as _fs} from "fs"; +>default : any +>_fs : any + +_fs.readFile; +>_fs.readFile : any +>_fs : any +>readFile : any + +import * as fs from "fs"; +>fs : any + +fs.readFile; +>fs.readFile : any +>fs : any +>readFile : any + +=== tests/cases/conformance/node/allowJs/types.d.ts === +declare module "fs"; +>"fs" : any + +declare module "tslib" { +>"tslib" : typeof import("tslib") + + export {}; + // intentionally missing all helpers +} diff --git a/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=node12).errors.txt b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=node12).errors.txt new file mode 100644 index 0000000000000..e07871859dbc2 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=node12).errors.txt @@ -0,0 +1,32 @@ +tests/cases/conformance/node/allowJs/subfolder/index.ts(2,1): error TS2343: This syntax requires an imported helper named '__exportStar' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. +tests/cases/conformance/node/allowJs/subfolder/index.ts(3,1): error TS2343: This syntax requires an imported helper named '__importStar' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. + + +==== tests/cases/conformance/node/allowJs/subfolder/index.ts (2 errors) ==== + // cjs format file + export * from "fs"; + ~~~~~~~~~~~~~~~~~~~ +!!! error TS2343: This syntax requires an imported helper named '__exportStar' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. + export * as fs from "fs"; + ~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2343: This syntax requires an imported helper named '__importStar' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. +==== tests/cases/conformance/node/allowJs/index.js (0 errors) ==== + // esm format file + export * from "fs"; + export * as fs from "fs"; +==== tests/cases/conformance/node/allowJs/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module" + } +==== tests/cases/conformance/node/allowJs/subfolder/package.json (0 errors) ==== + { + "type": "commonjs" + } +==== tests/cases/conformance/node/allowJs/types.d.ts (0 errors) ==== + declare module "fs"; + declare module "tslib" { + export {}; + // intentionally missing all helpers + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=node12).js b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=node12).js new file mode 100644 index 0000000000000..e23bc86265999 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=node12).js @@ -0,0 +1,48 @@ +//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportHelpersCollisions2.ts] //// + +//// [index.ts] +// cjs format file +export * from "fs"; +export * as fs from "fs"; +//// [index.js] +// esm format file +export * from "fs"; +export * as fs from "fs"; +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} +//// [types.d.ts] +declare module "fs"; +declare module "tslib" { + export {}; + // intentionally missing all helpers +} + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.fs = void 0; +const tslib_1 = require("tslib"); +// cjs format file +(0, tslib_1.__exportStar)(require("fs"), exports); +exports.fs = (0, tslib_1.__importStar)(require("fs")); +//// [index.js] +// esm format file +export * from "fs"; +export * as fs from "fs"; + + +//// [index.d.ts] +export * from "fs"; +export * as fs from "fs"; +//// [index.d.ts] +/// +export * from "fs"; +export * as fs from "fs"; diff --git a/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=node12).symbols b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=node12).symbols new file mode 100644 index 0000000000000..46c533db2dc75 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=node12).symbols @@ -0,0 +1,22 @@ +=== tests/cases/conformance/node/allowJs/subfolder/index.ts === +// cjs format file +export * from "fs"; +export * as fs from "fs"; +>fs : Symbol(fs, Decl(index.ts, 2, 6)) + +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +export * from "fs"; +export * as fs from "fs"; +>fs : Symbol(fs, Decl(index.js, 2, 6)) + +=== tests/cases/conformance/node/allowJs/types.d.ts === +declare module "fs"; +>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0)) + +declare module "tslib" { +>"tslib" : Symbol("tslib", Decl(types.d.ts, 0, 20)) + + export {}; + // intentionally missing all helpers +} diff --git a/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=node12).types b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=node12).types new file mode 100644 index 0000000000000..bbcb3d2993101 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=node12).types @@ -0,0 +1,22 @@ +=== tests/cases/conformance/node/allowJs/subfolder/index.ts === +// cjs format file +export * from "fs"; +export * as fs from "fs"; +>fs : any + +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +export * from "fs"; +export * as fs from "fs"; +>fs : any + +=== tests/cases/conformance/node/allowJs/types.d.ts === +declare module "fs"; +>"fs" : any + +declare module "tslib" { +>"tslib" : typeof import("tslib") + + export {}; + // intentionally missing all helpers +} diff --git a/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=nodenext).errors.txt new file mode 100644 index 0000000000000..e07871859dbc2 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=nodenext).errors.txt @@ -0,0 +1,32 @@ +tests/cases/conformance/node/allowJs/subfolder/index.ts(2,1): error TS2343: This syntax requires an imported helper named '__exportStar' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. +tests/cases/conformance/node/allowJs/subfolder/index.ts(3,1): error TS2343: This syntax requires an imported helper named '__importStar' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. + + +==== tests/cases/conformance/node/allowJs/subfolder/index.ts (2 errors) ==== + // cjs format file + export * from "fs"; + ~~~~~~~~~~~~~~~~~~~ +!!! error TS2343: This syntax requires an imported helper named '__exportStar' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. + export * as fs from "fs"; + ~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2343: This syntax requires an imported helper named '__importStar' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. +==== tests/cases/conformance/node/allowJs/index.js (0 errors) ==== + // esm format file + export * from "fs"; + export * as fs from "fs"; +==== tests/cases/conformance/node/allowJs/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module" + } +==== tests/cases/conformance/node/allowJs/subfolder/package.json (0 errors) ==== + { + "type": "commonjs" + } +==== tests/cases/conformance/node/allowJs/types.d.ts (0 errors) ==== + declare module "fs"; + declare module "tslib" { + export {}; + // intentionally missing all helpers + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=nodenext).js b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=nodenext).js new file mode 100644 index 0000000000000..e23bc86265999 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=nodenext).js @@ -0,0 +1,48 @@ +//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportHelpersCollisions2.ts] //// + +//// [index.ts] +// cjs format file +export * from "fs"; +export * as fs from "fs"; +//// [index.js] +// esm format file +export * from "fs"; +export * as fs from "fs"; +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} +//// [types.d.ts] +declare module "fs"; +declare module "tslib" { + export {}; + // intentionally missing all helpers +} + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.fs = void 0; +const tslib_1 = require("tslib"); +// cjs format file +(0, tslib_1.__exportStar)(require("fs"), exports); +exports.fs = (0, tslib_1.__importStar)(require("fs")); +//// [index.js] +// esm format file +export * from "fs"; +export * as fs from "fs"; + + +//// [index.d.ts] +export * from "fs"; +export * as fs from "fs"; +//// [index.d.ts] +/// +export * from "fs"; +export * as fs from "fs"; diff --git a/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=nodenext).symbols b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=nodenext).symbols new file mode 100644 index 0000000000000..46c533db2dc75 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=nodenext).symbols @@ -0,0 +1,22 @@ +=== tests/cases/conformance/node/allowJs/subfolder/index.ts === +// cjs format file +export * from "fs"; +export * as fs from "fs"; +>fs : Symbol(fs, Decl(index.ts, 2, 6)) + +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +export * from "fs"; +export * as fs from "fs"; +>fs : Symbol(fs, Decl(index.js, 2, 6)) + +=== tests/cases/conformance/node/allowJs/types.d.ts === +declare module "fs"; +>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0)) + +declare module "tslib" { +>"tslib" : Symbol("tslib", Decl(types.d.ts, 0, 20)) + + export {}; + // intentionally missing all helpers +} diff --git a/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=nodenext).types b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=nodenext).types new file mode 100644 index 0000000000000..bbcb3d2993101 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions2(module=nodenext).types @@ -0,0 +1,22 @@ +=== tests/cases/conformance/node/allowJs/subfolder/index.ts === +// cjs format file +export * from "fs"; +export * as fs from "fs"; +>fs : any + +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +export * from "fs"; +export * as fs from "fs"; +>fs : any + +=== tests/cases/conformance/node/allowJs/types.d.ts === +declare module "fs"; +>"fs" : any + +declare module "tslib" { +>"tslib" : typeof import("tslib") + + export {}; + // intentionally missing all helpers +} diff --git a/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=node12).errors.txt b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=node12).errors.txt new file mode 100644 index 0000000000000..cd8457101bb44 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=node12).errors.txt @@ -0,0 +1,31 @@ +tests/cases/conformance/node/allowJs/subfolder/index.js(2,9): error TS2343: This syntax requires an imported helper named '__importDefault' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. + + +==== tests/cases/conformance/node/allowJs/subfolder/index.js (1 errors) ==== + // cjs format file + export {default} from "fs"; + ~~~~~~~ +!!! error TS2343: This syntax requires an imported helper named '__importDefault' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. + export {default as foo} from "fs"; + export {bar as baz} from "fs"; +==== tests/cases/conformance/node/allowJs/index.js (0 errors) ==== + // esm format file + export {default} from "fs"; + export {default as foo} from "fs"; + export {bar as baz} from "fs"; +==== tests/cases/conformance/node/allowJs/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module" + } +==== tests/cases/conformance/node/allowJs/subfolder/package.json (0 errors) ==== + { + "type": "commonjs" + } +==== tests/cases/conformance/node/allowJs/types.d.ts (0 errors) ==== + declare module "fs"; + declare module "tslib" { + export {}; + // intentionally missing all helpers + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=node12).js b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=node12).js new file mode 100644 index 0000000000000..8e07883b7276b --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=node12).js @@ -0,0 +1,54 @@ +//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportHelpersCollisions3.ts] //// + +//// [index.js] +// cjs format file +export {default} from "fs"; +export {default as foo} from "fs"; +export {bar as baz} from "fs"; +//// [index.js] +// esm format file +export {default} from "fs"; +export {default as foo} from "fs"; +export {bar as baz} from "fs"; +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} +//// [types.d.ts] +declare module "fs"; +declare module "tslib" { + export {}; + // intentionally missing all helpers +} + +//// [index.js] +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.baz = exports.foo = exports.default = void 0; +// cjs format file +var fs_1 = require("fs"); +Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(fs_1).default; } }); +var fs_2 = require("fs"); +Object.defineProperty(exports, "foo", { enumerable: true, get: function () { return __importDefault(fs_2).default; } }); +var fs_3 = require("fs"); +Object.defineProperty(exports, "baz", { enumerable: true, get: function () { return fs_3.bar; } }); +//// [index.js] +// esm format file +export { default } from "fs"; +export { default as foo } from "fs"; +export { bar as baz } from "fs"; + + +//// [index.d.ts] +export { default, default as foo, bar as baz } from "fs"; +//// [index.d.ts] +export { default, default as foo, bar as baz } from "fs"; diff --git a/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=node12).symbols b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=node12).symbols new file mode 100644 index 0000000000000..767be993d649b --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=node12).symbols @@ -0,0 +1,36 @@ +=== tests/cases/conformance/node/allowJs/subfolder/index.js === +// cjs format file +export {default} from "fs"; +>default : Symbol(default, Decl(index.js, 1, 8)) + +export {default as foo} from "fs"; +>default : Symbol("fs", Decl(types.d.ts, 0, 0)) +>foo : Symbol(foo, Decl(index.js, 2, 8)) + +export {bar as baz} from "fs"; +>bar : Symbol("fs", Decl(types.d.ts, 0, 0)) +>baz : Symbol(baz, Decl(index.js, 3, 8)) + +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +export {default} from "fs"; +>default : Symbol(default, Decl(index.js, 1, 8)) + +export {default as foo} from "fs"; +>default : Symbol("fs", Decl(types.d.ts, 0, 0)) +>foo : Symbol(foo, Decl(index.js, 2, 8)) + +export {bar as baz} from "fs"; +>bar : Symbol("fs", Decl(types.d.ts, 0, 0)) +>baz : Symbol(baz, Decl(index.js, 3, 8)) + +=== tests/cases/conformance/node/allowJs/types.d.ts === +declare module "fs"; +>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0)) + +declare module "tslib" { +>"tslib" : Symbol("tslib", Decl(types.d.ts, 0, 20)) + + export {}; + // intentionally missing all helpers +} diff --git a/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=node12).types b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=node12).types new file mode 100644 index 0000000000000..b07207ec08de4 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=node12).types @@ -0,0 +1,36 @@ +=== tests/cases/conformance/node/allowJs/subfolder/index.js === +// cjs format file +export {default} from "fs"; +>default : any + +export {default as foo} from "fs"; +>default : any +>foo : any + +export {bar as baz} from "fs"; +>bar : any +>baz : any + +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +export {default} from "fs"; +>default : any + +export {default as foo} from "fs"; +>default : any +>foo : any + +export {bar as baz} from "fs"; +>bar : any +>baz : any + +=== tests/cases/conformance/node/allowJs/types.d.ts === +declare module "fs"; +>"fs" : any + +declare module "tslib" { +>"tslib" : typeof import("tslib") + + export {}; + // intentionally missing all helpers +} diff --git a/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=nodenext).errors.txt new file mode 100644 index 0000000000000..cd8457101bb44 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=nodenext).errors.txt @@ -0,0 +1,31 @@ +tests/cases/conformance/node/allowJs/subfolder/index.js(2,9): error TS2343: This syntax requires an imported helper named '__importDefault' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. + + +==== tests/cases/conformance/node/allowJs/subfolder/index.js (1 errors) ==== + // cjs format file + export {default} from "fs"; + ~~~~~~~ +!!! error TS2343: This syntax requires an imported helper named '__importDefault' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. + export {default as foo} from "fs"; + export {bar as baz} from "fs"; +==== tests/cases/conformance/node/allowJs/index.js (0 errors) ==== + // esm format file + export {default} from "fs"; + export {default as foo} from "fs"; + export {bar as baz} from "fs"; +==== tests/cases/conformance/node/allowJs/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module" + } +==== tests/cases/conformance/node/allowJs/subfolder/package.json (0 errors) ==== + { + "type": "commonjs" + } +==== tests/cases/conformance/node/allowJs/types.d.ts (0 errors) ==== + declare module "fs"; + declare module "tslib" { + export {}; + // intentionally missing all helpers + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=nodenext).js b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=nodenext).js new file mode 100644 index 0000000000000..8e07883b7276b --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=nodenext).js @@ -0,0 +1,54 @@ +//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportHelpersCollisions3.ts] //// + +//// [index.js] +// cjs format file +export {default} from "fs"; +export {default as foo} from "fs"; +export {bar as baz} from "fs"; +//// [index.js] +// esm format file +export {default} from "fs"; +export {default as foo} from "fs"; +export {bar as baz} from "fs"; +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} +//// [types.d.ts] +declare module "fs"; +declare module "tslib" { + export {}; + // intentionally missing all helpers +} + +//// [index.js] +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.baz = exports.foo = exports.default = void 0; +// cjs format file +var fs_1 = require("fs"); +Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(fs_1).default; } }); +var fs_2 = require("fs"); +Object.defineProperty(exports, "foo", { enumerable: true, get: function () { return __importDefault(fs_2).default; } }); +var fs_3 = require("fs"); +Object.defineProperty(exports, "baz", { enumerable: true, get: function () { return fs_3.bar; } }); +//// [index.js] +// esm format file +export { default } from "fs"; +export { default as foo } from "fs"; +export { bar as baz } from "fs"; + + +//// [index.d.ts] +export { default, default as foo, bar as baz } from "fs"; +//// [index.d.ts] +export { default, default as foo, bar as baz } from "fs"; diff --git a/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=nodenext).symbols b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=nodenext).symbols new file mode 100644 index 0000000000000..767be993d649b --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=nodenext).symbols @@ -0,0 +1,36 @@ +=== tests/cases/conformance/node/allowJs/subfolder/index.js === +// cjs format file +export {default} from "fs"; +>default : Symbol(default, Decl(index.js, 1, 8)) + +export {default as foo} from "fs"; +>default : Symbol("fs", Decl(types.d.ts, 0, 0)) +>foo : Symbol(foo, Decl(index.js, 2, 8)) + +export {bar as baz} from "fs"; +>bar : Symbol("fs", Decl(types.d.ts, 0, 0)) +>baz : Symbol(baz, Decl(index.js, 3, 8)) + +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +export {default} from "fs"; +>default : Symbol(default, Decl(index.js, 1, 8)) + +export {default as foo} from "fs"; +>default : Symbol("fs", Decl(types.d.ts, 0, 0)) +>foo : Symbol(foo, Decl(index.js, 2, 8)) + +export {bar as baz} from "fs"; +>bar : Symbol("fs", Decl(types.d.ts, 0, 0)) +>baz : Symbol(baz, Decl(index.js, 3, 8)) + +=== tests/cases/conformance/node/allowJs/types.d.ts === +declare module "fs"; +>"fs" : Symbol("fs", Decl(types.d.ts, 0, 0)) + +declare module "tslib" { +>"tslib" : Symbol("tslib", Decl(types.d.ts, 0, 20)) + + export {}; + // intentionally missing all helpers +} diff --git a/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=nodenext).types b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=nodenext).types new file mode 100644 index 0000000000000..b07207ec08de4 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsImportHelpersCollisions3(module=nodenext).types @@ -0,0 +1,36 @@ +=== tests/cases/conformance/node/allowJs/subfolder/index.js === +// cjs format file +export {default} from "fs"; +>default : any + +export {default as foo} from "fs"; +>default : any +>foo : any + +export {bar as baz} from "fs"; +>bar : any +>baz : any + +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +export {default} from "fs"; +>default : any + +export {default as foo} from "fs"; +>default : any +>foo : any + +export {bar as baz} from "fs"; +>bar : any +>baz : any + +=== tests/cases/conformance/node/allowJs/types.d.ts === +declare module "fs"; +>"fs" : any + +declare module "tslib" { +>"tslib" : typeof import("tslib") + + export {}; + // intentionally missing all helpers +} diff --git a/tests/baselines/reference/nodeModulesAllowJsImportMeta(module=node12).errors.txt b/tests/baselines/reference/nodeModulesAllowJsImportMeta(module=node12).errors.txt new file mode 100644 index 0000000000000..1c029f89a5e71 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsImportMeta(module=node12).errors.txt @@ -0,0 +1,23 @@ +tests/cases/conformance/node/allowJs/subfolder/index.js(2,11): error TS1434: The 'import.meta' meta-property is not allowed in files which will build into CommonJS output. + + +==== tests/cases/conformance/node/allowJs/subfolder/index.js (1 errors) ==== + // cjs format file + const x = import.meta.url; + ~~~~~~~~~~~ +!!! error TS1434: The 'import.meta' meta-property is not allowed in files which will build into CommonJS output. + export {x}; +==== tests/cases/conformance/node/allowJs/index.js (0 errors) ==== + // esm format file + const x = import.meta.url; + export {x}; +==== tests/cases/conformance/node/allowJs/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module" + } +==== tests/cases/conformance/node/allowJs/subfolder/package.json (0 errors) ==== + { + "type": "commonjs" + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesAllowJsImportMeta(module=node12).js b/tests/baselines/reference/nodeModulesAllowJsImportMeta(module=node12).js new file mode 100644 index 0000000000000..7e6d01b7daf2a --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsImportMeta(module=node12).js @@ -0,0 +1,38 @@ +//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportMeta.ts] //// + +//// [index.js] +// cjs format file +const x = import.meta.url; +export {x}; +//// [index.js] +// esm format file +const x = import.meta.url; +export {x}; +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +// cjs format file +const x = import.meta.url; +exports.x = x; +//// [index.js] +// esm format file +const x = import.meta.url; +export { x }; + + +//// [index.d.ts] +export const x: string; +//// [index.d.ts] +export const x: string; diff --git a/tests/baselines/reference/nodeModulesAllowJsImportMeta(module=node12).symbols b/tests/baselines/reference/nodeModulesAllowJsImportMeta(module=node12).symbols new file mode 100644 index 0000000000000..d330e94300513 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsImportMeta(module=node12).symbols @@ -0,0 +1,20 @@ +=== tests/cases/conformance/node/allowJs/subfolder/index.js === +// cjs format file +const x = import.meta.url; +>x : Symbol(x, Decl(index.js, 1, 5)) +>import.meta.url : Symbol(ImportMeta.url, Decl(lib.dom.d.ts, --, --)) +>url : Symbol(ImportMeta.url, Decl(lib.dom.d.ts, --, --)) + +export {x}; +>x : Symbol(x, Decl(index.js, 2, 8)) + +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +const x = import.meta.url; +>x : Symbol(x, Decl(index.js, 1, 5)) +>import.meta.url : Symbol(ImportMeta.url, Decl(lib.dom.d.ts, --, --)) +>url : Symbol(ImportMeta.url, Decl(lib.dom.d.ts, --, --)) + +export {x}; +>x : Symbol(x, Decl(index.js, 2, 8)) + diff --git a/tests/baselines/reference/nodeModulesAllowJsImportMeta(module=node12).types b/tests/baselines/reference/nodeModulesAllowJsImportMeta(module=node12).types new file mode 100644 index 0000000000000..de6d0c96059f4 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsImportMeta(module=node12).types @@ -0,0 +1,24 @@ +=== tests/cases/conformance/node/allowJs/subfolder/index.js === +// cjs format file +const x = import.meta.url; +>x : string +>import.meta.url : string +>import.meta : ImportMeta +>meta : any +>url : string + +export {x}; +>x : string + +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +const x = import.meta.url; +>x : string +>import.meta.url : string +>import.meta : ImportMeta +>meta : any +>url : string + +export {x}; +>x : string + diff --git a/tests/baselines/reference/nodeModulesAllowJsImportMeta(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesAllowJsImportMeta(module=nodenext).errors.txt new file mode 100644 index 0000000000000..1c029f89a5e71 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsImportMeta(module=nodenext).errors.txt @@ -0,0 +1,23 @@ +tests/cases/conformance/node/allowJs/subfolder/index.js(2,11): error TS1434: The 'import.meta' meta-property is not allowed in files which will build into CommonJS output. + + +==== tests/cases/conformance/node/allowJs/subfolder/index.js (1 errors) ==== + // cjs format file + const x = import.meta.url; + ~~~~~~~~~~~ +!!! error TS1434: The 'import.meta' meta-property is not allowed in files which will build into CommonJS output. + export {x}; +==== tests/cases/conformance/node/allowJs/index.js (0 errors) ==== + // esm format file + const x = import.meta.url; + export {x}; +==== tests/cases/conformance/node/allowJs/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module" + } +==== tests/cases/conformance/node/allowJs/subfolder/package.json (0 errors) ==== + { + "type": "commonjs" + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesAllowJsImportMeta(module=nodenext).js b/tests/baselines/reference/nodeModulesAllowJsImportMeta(module=nodenext).js new file mode 100644 index 0000000000000..7e6d01b7daf2a --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsImportMeta(module=nodenext).js @@ -0,0 +1,38 @@ +//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportMeta.ts] //// + +//// [index.js] +// cjs format file +const x = import.meta.url; +export {x}; +//// [index.js] +// esm format file +const x = import.meta.url; +export {x}; +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +// cjs format file +const x = import.meta.url; +exports.x = x; +//// [index.js] +// esm format file +const x = import.meta.url; +export { x }; + + +//// [index.d.ts] +export const x: string; +//// [index.d.ts] +export const x: string; diff --git a/tests/baselines/reference/nodeModulesAllowJsImportMeta(module=nodenext).symbols b/tests/baselines/reference/nodeModulesAllowJsImportMeta(module=nodenext).symbols new file mode 100644 index 0000000000000..d330e94300513 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsImportMeta(module=nodenext).symbols @@ -0,0 +1,20 @@ +=== tests/cases/conformance/node/allowJs/subfolder/index.js === +// cjs format file +const x = import.meta.url; +>x : Symbol(x, Decl(index.js, 1, 5)) +>import.meta.url : Symbol(ImportMeta.url, Decl(lib.dom.d.ts, --, --)) +>url : Symbol(ImportMeta.url, Decl(lib.dom.d.ts, --, --)) + +export {x}; +>x : Symbol(x, Decl(index.js, 2, 8)) + +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +const x = import.meta.url; +>x : Symbol(x, Decl(index.js, 1, 5)) +>import.meta.url : Symbol(ImportMeta.url, Decl(lib.dom.d.ts, --, --)) +>url : Symbol(ImportMeta.url, Decl(lib.dom.d.ts, --, --)) + +export {x}; +>x : Symbol(x, Decl(index.js, 2, 8)) + diff --git a/tests/baselines/reference/nodeModulesAllowJsImportMeta(module=nodenext).types b/tests/baselines/reference/nodeModulesAllowJsImportMeta(module=nodenext).types new file mode 100644 index 0000000000000..de6d0c96059f4 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsImportMeta(module=nodenext).types @@ -0,0 +1,24 @@ +=== tests/cases/conformance/node/allowJs/subfolder/index.js === +// cjs format file +const x = import.meta.url; +>x : string +>import.meta.url : string +>import.meta : ImportMeta +>meta : any +>url : string + +export {x}; +>x : string + +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +const x = import.meta.url; +>x : string +>import.meta.url : string +>import.meta : ImportMeta +>meta : any +>url : string + +export {x}; +>x : string + diff --git a/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=node12).errors.txt b/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=node12).errors.txt new file mode 100644 index 0000000000000..da424074020aa --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=node12).errors.txt @@ -0,0 +1,55 @@ +tests/cases/conformance/node/allowJs/index.js(3,1): error TS8002: 'import ... =' can only be used in TypeScript files. +tests/cases/conformance/node/allowJs/index.js(3,22): error TS1435: Module './index.js' 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.js(5,1): error TS8002: 'import ... =' can only be used in TypeScript files. +tests/cases/conformance/node/allowJs/subfolder/index.js(2,17): error TS1435: Module '../index.js' 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/subfolder/index.js(3,1): error TS8002: 'import ... =' can only be used in TypeScript files. +tests/cases/conformance/node/allowJs/subfolder/index.js(3,22): error TS1435: Module '../index.js' 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/subfolder/index.js(5,1): error TS8002: 'import ... =' can only be used in TypeScript files. + + +==== tests/cases/conformance/node/allowJs/subfolder/index.js (4 errors) ==== + // cjs format file + import {h} from "../index.js"; + ~~~~~~~~~~~~~ +!!! error TS1435: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. + import mod = require("../index.js"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~ +!!! error TS1435: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. + import {f as _f} from "./index.js"; + import mod2 = require("./index.js"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + export async function f() { + const mod3 = await import ("../index.js"); + const mod4 = await import ("./index.js"); + h(); + } +==== tests/cases/conformance/node/allowJs/index.js (3 errors) ==== + // esm format file + import {h as _h} from "./index.js"; + import mod = require("./index.js"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~ +!!! error TS1435: Module './index.js' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. + import {f} from "./subfolder/index.js"; + import mod2 = require("./subfolder/index.js"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + export async function h() { + const mod3 = await import ("./index.js"); + const mod4 = await import ("./subfolder/index.js"); + f(); + } +==== tests/cases/conformance/node/allowJs/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module" + } +==== tests/cases/conformance/node/allowJs/subfolder/package.json (0 errors) ==== + { + "type": "commonjs" + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=node12).js b/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=node12).js new file mode 100644 index 0000000000000..a02ef88f1e524 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=node12).js @@ -0,0 +1,60 @@ +//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsSynchronousCallErrors.ts] //// + +//// [index.js] +// cjs format file +import {h} from "../index.js"; +import mod = require("../index.js"); +import {f as _f} from "./index.js"; +import mod2 = require("./index.js"); +export async function f() { + const mod3 = await import ("../index.js"); + const mod4 = await import ("./index.js"); + h(); +} +//// [index.js] +// esm format file +import {h as _h} from "./index.js"; +import mod = require("./index.js"); +import {f} from "./subfolder/index.js"; +import mod2 = require("./subfolder/index.js"); +export async function h() { + const mod3 = await import ("./index.js"); + const mod4 = await import ("./subfolder/index.js"); + f(); +} +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} + +//// [index.js] +import { f } from "./subfolder/index.js"; +export async function h() { + const mod3 = await import("./index.js"); + const mod4 = await import("./subfolder/index.js"); + f(); +} +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.f = void 0; +// cjs format file +const index_js_1 = require("../index.js"); +async function f() { + const mod3 = await import("../index.js"); + const mod4 = await import("./index.js"); + (0, index_js_1.h)(); +} +exports.f = f; + + +//// [index.d.ts] +export function h(): Promise; +//// [index.d.ts] +export function f(): Promise; diff --git a/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=node12).symbols b/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=node12).symbols new file mode 100644 index 0000000000000..8cbba01b82f62 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=node12).symbols @@ -0,0 +1,58 @@ +=== tests/cases/conformance/node/allowJs/subfolder/index.js === +// cjs format file +import {h} from "../index.js"; +>h : Symbol(h, Decl(index.js, 1, 8)) + +import mod = require("../index.js"); +>mod : Symbol(mod, Decl(index.js, 1, 30)) + +import {f as _f} from "./index.js"; +>f : Symbol(f, Decl(index.js, 4, 36)) +>_f : Symbol(_f, Decl(index.js, 3, 8)) + +import mod2 = require("./index.js"); +>mod2 : Symbol(mod2, Decl(index.js, 3, 35)) + +export async function f() { +>f : Symbol(f, Decl(index.js, 4, 36)) + + const mod3 = await import ("../index.js"); +>mod3 : Symbol(mod3, Decl(index.js, 6, 9)) +>"../index.js" : Symbol(mod, Decl(index.js, 0, 0)) + + const mod4 = await import ("./index.js"); +>mod4 : Symbol(mod4, Decl(index.js, 7, 9)) +>"./index.js" : Symbol(mod2, Decl(index.js, 0, 0)) + + h(); +>h : Symbol(h, Decl(index.js, 1, 8)) +} +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +import {h as _h} from "./index.js"; +>h : Symbol(h, Decl(index.js, 4, 46)) +>_h : Symbol(_h, Decl(index.js, 1, 8)) + +import mod = require("./index.js"); +>mod : Symbol(mod, Decl(index.js, 1, 35)) + +import {f} from "./subfolder/index.js"; +>f : Symbol(f, Decl(index.js, 3, 8)) + +import mod2 = require("./subfolder/index.js"); +>mod2 : Symbol(mod2, Decl(index.js, 3, 39)) + +export async function h() { +>h : Symbol(h, Decl(index.js, 4, 46)) + + const mod3 = await import ("./index.js"); +>mod3 : Symbol(mod3, Decl(index.js, 6, 9)) +>"./index.js" : Symbol(mod, Decl(index.js, 0, 0)) + + const mod4 = await import ("./subfolder/index.js"); +>mod4 : Symbol(mod4, Decl(index.js, 7, 9)) +>"./subfolder/index.js" : Symbol(mod2, Decl(index.js, 0, 0)) + + f(); +>f : Symbol(f, Decl(index.js, 3, 8)) +} diff --git a/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=node12).types b/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=node12).types new file mode 100644 index 0000000000000..77061e385af3a --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=node12).types @@ -0,0 +1,68 @@ +=== tests/cases/conformance/node/allowJs/subfolder/index.js === +// cjs format file +import {h} from "../index.js"; +>h : () => Promise + +import mod = require("../index.js"); +>mod : typeof mod + +import {f as _f} from "./index.js"; +>f : () => Promise +>_f : () => Promise + +import mod2 = require("./index.js"); +>mod2 : typeof mod2 + +export async function f() { +>f : () => Promise + + const mod3 = await import ("../index.js"); +>mod3 : typeof mod +>await import ("../index.js") : typeof mod +>import ("../index.js") : Promise +>"../index.js" : "../index.js" + + const mod4 = await import ("./index.js"); +>mod4 : typeof mod2 +>await import ("./index.js") : typeof mod2 +>import ("./index.js") : Promise +>"./index.js" : "./index.js" + + h(); +>h() : Promise +>h : () => Promise +} +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +import {h as _h} from "./index.js"; +>h : () => Promise +>_h : () => Promise + +import mod = require("./index.js"); +>mod : typeof mod + +import {f} from "./subfolder/index.js"; +>f : () => Promise + +import mod2 = require("./subfolder/index.js"); +>mod2 : typeof mod2 + +export async function h() { +>h : () => Promise + + const mod3 = await import ("./index.js"); +>mod3 : typeof mod +>await import ("./index.js") : typeof mod +>import ("./index.js") : Promise +>"./index.js" : "./index.js" + + const mod4 = await import ("./subfolder/index.js"); +>mod4 : typeof mod2 +>await import ("./subfolder/index.js") : typeof mod2 +>import ("./subfolder/index.js") : Promise +>"./subfolder/index.js" : "./subfolder/index.js" + + f(); +>f() : Promise +>f : () => Promise +} diff --git a/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=nodenext).errors.txt new file mode 100644 index 0000000000000..da424074020aa --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=nodenext).errors.txt @@ -0,0 +1,55 @@ +tests/cases/conformance/node/allowJs/index.js(3,1): error TS8002: 'import ... =' can only be used in TypeScript files. +tests/cases/conformance/node/allowJs/index.js(3,22): error TS1435: Module './index.js' 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.js(5,1): error TS8002: 'import ... =' can only be used in TypeScript files. +tests/cases/conformance/node/allowJs/subfolder/index.js(2,17): error TS1435: Module '../index.js' 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/subfolder/index.js(3,1): error TS8002: 'import ... =' can only be used in TypeScript files. +tests/cases/conformance/node/allowJs/subfolder/index.js(3,22): error TS1435: Module '../index.js' 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/subfolder/index.js(5,1): error TS8002: 'import ... =' can only be used in TypeScript files. + + +==== tests/cases/conformance/node/allowJs/subfolder/index.js (4 errors) ==== + // cjs format file + import {h} from "../index.js"; + ~~~~~~~~~~~~~ +!!! error TS1435: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. + import mod = require("../index.js"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~~ +!!! error TS1435: Module '../index.js' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. + import {f as _f} from "./index.js"; + import mod2 = require("./index.js"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + export async function f() { + const mod3 = await import ("../index.js"); + const mod4 = await import ("./index.js"); + h(); + } +==== tests/cases/conformance/node/allowJs/index.js (3 errors) ==== + // esm format file + import {h as _h} from "./index.js"; + import mod = require("./index.js"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + ~~~~~~~~~~~~ +!!! error TS1435: Module './index.js' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. + import {f} from "./subfolder/index.js"; + import mod2 = require("./subfolder/index.js"); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS8002: 'import ... =' can only be used in TypeScript files. + export async function h() { + const mod3 = await import ("./index.js"); + const mod4 = await import ("./subfolder/index.js"); + f(); + } +==== tests/cases/conformance/node/allowJs/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module" + } +==== tests/cases/conformance/node/allowJs/subfolder/package.json (0 errors) ==== + { + "type": "commonjs" + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=nodenext).js b/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=nodenext).js new file mode 100644 index 0000000000000..a02ef88f1e524 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=nodenext).js @@ -0,0 +1,60 @@ +//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsSynchronousCallErrors.ts] //// + +//// [index.js] +// cjs format file +import {h} from "../index.js"; +import mod = require("../index.js"); +import {f as _f} from "./index.js"; +import mod2 = require("./index.js"); +export async function f() { + const mod3 = await import ("../index.js"); + const mod4 = await import ("./index.js"); + h(); +} +//// [index.js] +// esm format file +import {h as _h} from "./index.js"; +import mod = require("./index.js"); +import {f} from "./subfolder/index.js"; +import mod2 = require("./subfolder/index.js"); +export async function h() { + const mod3 = await import ("./index.js"); + const mod4 = await import ("./subfolder/index.js"); + f(); +} +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} + +//// [index.js] +import { f } from "./subfolder/index.js"; +export async function h() { + const mod3 = await import("./index.js"); + const mod4 = await import("./subfolder/index.js"); + f(); +} +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.f = void 0; +// cjs format file +const index_js_1 = require("../index.js"); +async function f() { + const mod3 = await import("../index.js"); + const mod4 = await import("./index.js"); + (0, index_js_1.h)(); +} +exports.f = f; + + +//// [index.d.ts] +export function h(): Promise; +//// [index.d.ts] +export function f(): Promise; diff --git a/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=nodenext).symbols b/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=nodenext).symbols new file mode 100644 index 0000000000000..8cbba01b82f62 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=nodenext).symbols @@ -0,0 +1,58 @@ +=== tests/cases/conformance/node/allowJs/subfolder/index.js === +// cjs format file +import {h} from "../index.js"; +>h : Symbol(h, Decl(index.js, 1, 8)) + +import mod = require("../index.js"); +>mod : Symbol(mod, Decl(index.js, 1, 30)) + +import {f as _f} from "./index.js"; +>f : Symbol(f, Decl(index.js, 4, 36)) +>_f : Symbol(_f, Decl(index.js, 3, 8)) + +import mod2 = require("./index.js"); +>mod2 : Symbol(mod2, Decl(index.js, 3, 35)) + +export async function f() { +>f : Symbol(f, Decl(index.js, 4, 36)) + + const mod3 = await import ("../index.js"); +>mod3 : Symbol(mod3, Decl(index.js, 6, 9)) +>"../index.js" : Symbol(mod, Decl(index.js, 0, 0)) + + const mod4 = await import ("./index.js"); +>mod4 : Symbol(mod4, Decl(index.js, 7, 9)) +>"./index.js" : Symbol(mod2, Decl(index.js, 0, 0)) + + h(); +>h : Symbol(h, Decl(index.js, 1, 8)) +} +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +import {h as _h} from "./index.js"; +>h : Symbol(h, Decl(index.js, 4, 46)) +>_h : Symbol(_h, Decl(index.js, 1, 8)) + +import mod = require("./index.js"); +>mod : Symbol(mod, Decl(index.js, 1, 35)) + +import {f} from "./subfolder/index.js"; +>f : Symbol(f, Decl(index.js, 3, 8)) + +import mod2 = require("./subfolder/index.js"); +>mod2 : Symbol(mod2, Decl(index.js, 3, 39)) + +export async function h() { +>h : Symbol(h, Decl(index.js, 4, 46)) + + const mod3 = await import ("./index.js"); +>mod3 : Symbol(mod3, Decl(index.js, 6, 9)) +>"./index.js" : Symbol(mod, Decl(index.js, 0, 0)) + + const mod4 = await import ("./subfolder/index.js"); +>mod4 : Symbol(mod4, Decl(index.js, 7, 9)) +>"./subfolder/index.js" : Symbol(mod2, Decl(index.js, 0, 0)) + + f(); +>f : Symbol(f, Decl(index.js, 3, 8)) +} diff --git a/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=nodenext).types b/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=nodenext).types new file mode 100644 index 0000000000000..77061e385af3a --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsSynchronousCallErrors(module=nodenext).types @@ -0,0 +1,68 @@ +=== tests/cases/conformance/node/allowJs/subfolder/index.js === +// cjs format file +import {h} from "../index.js"; +>h : () => Promise + +import mod = require("../index.js"); +>mod : typeof mod + +import {f as _f} from "./index.js"; +>f : () => Promise +>_f : () => Promise + +import mod2 = require("./index.js"); +>mod2 : typeof mod2 + +export async function f() { +>f : () => Promise + + const mod3 = await import ("../index.js"); +>mod3 : typeof mod +>await import ("../index.js") : typeof mod +>import ("../index.js") : Promise +>"../index.js" : "../index.js" + + const mod4 = await import ("./index.js"); +>mod4 : typeof mod2 +>await import ("./index.js") : typeof mod2 +>import ("./index.js") : Promise +>"./index.js" : "./index.js" + + h(); +>h() : Promise +>h : () => Promise +} +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +import {h as _h} from "./index.js"; +>h : () => Promise +>_h : () => Promise + +import mod = require("./index.js"); +>mod : typeof mod + +import {f} from "./subfolder/index.js"; +>f : () => Promise + +import mod2 = require("./subfolder/index.js"); +>mod2 : typeof mod2 + +export async function h() { +>h : () => Promise + + const mod3 = await import ("./index.js"); +>mod3 : typeof mod +>await import ("./index.js") : typeof mod +>import ("./index.js") : Promise +>"./index.js" : "./index.js" + + const mod4 = await import ("./subfolder/index.js"); +>mod4 : typeof mod2 +>await import ("./subfolder/index.js") : typeof mod2 +>import ("./subfolder/index.js") : Promise +>"./subfolder/index.js" : "./subfolder/index.js" + + f(); +>f() : Promise +>f : () => Promise +} diff --git a/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=node12).errors.txt b/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=node12).errors.txt new file mode 100644 index 0000000000000..eff86eab7e9d6 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=node12).errors.txt @@ -0,0 +1,34 @@ +tests/cases/conformance/node/allowJs/index.js(2,11): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +tests/cases/conformance/node/allowJs/index.js(4,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +tests/cases/conformance/node/allowJs/subfolder/index.js(2,11): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +tests/cases/conformance/node/allowJs/subfolder/index.js(4,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. + + +==== tests/cases/conformance/node/allowJs/subfolder/index.js (2 errors) ==== + // cjs format file + const x = await 1; + ~~~~~ +!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. + export {x}; + for await (const y of []) {} + ~~~~~ +!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +==== tests/cases/conformance/node/allowJs/index.js (2 errors) ==== + // esm format file + const x = await 1; + ~~~~~ +!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. + export {x}; + for await (const y of []) {} + ~~~~~ +!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +==== tests/cases/conformance/node/allowJs/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module" + } +==== tests/cases/conformance/node/allowJs/subfolder/package.json (0 errors) ==== + { + "type": "commonjs" + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=node12).js b/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=node12).js new file mode 100644 index 0000000000000..354fe725f0960 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=node12).js @@ -0,0 +1,42 @@ +//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsTopLevelAwait.ts] //// + +//// [index.js] +// cjs format file +const x = await 1; +export {x}; +for await (const y of []) {} +//// [index.js] +// esm format file +const x = await 1; +export {x}; +for await (const y of []) {} +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +// cjs format file +const x = await 1; +exports.x = x; +for await (const y of []) { } +//// [index.js] +// esm format file +const x = await 1; +export { x }; +for await (const y of []) { } + + +//// [index.d.ts] +export const x: 1; +//// [index.d.ts] +export const x: 1; diff --git a/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=node12).symbols b/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=node12).symbols new file mode 100644 index 0000000000000..09ad69c019c70 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=node12).symbols @@ -0,0 +1,22 @@ +=== tests/cases/conformance/node/allowJs/subfolder/index.js === +// cjs format file +const x = await 1; +>x : Symbol(x, Decl(index.js, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.js, 2, 8)) + +for await (const y of []) {} +>y : Symbol(y, Decl(index.js, 3, 16)) + +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +const x = await 1; +>x : Symbol(x, Decl(index.js, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.js, 2, 8)) + +for await (const y of []) {} +>y : Symbol(y, Decl(index.js, 3, 16)) + diff --git a/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=node12).types b/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=node12).types new file mode 100644 index 0000000000000..b50bdd2c107e5 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=node12).types @@ -0,0 +1,28 @@ +=== tests/cases/conformance/node/allowJs/subfolder/index.js === +// cjs format file +const x = await 1; +>x : 1 +>await 1 : 1 +>1 : 1 + +export {x}; +>x : 1 + +for await (const y of []) {} +>y : any +>[] : undefined[] + +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +const x = await 1; +>x : 1 +>await 1 : 1 +>1 : 1 + +export {x}; +>x : 1 + +for await (const y of []) {} +>y : any +>[] : undefined[] + diff --git a/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=nodenext).errors.txt new file mode 100644 index 0000000000000..f2b3347f94df8 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=nodenext).errors.txt @@ -0,0 +1,28 @@ +tests/cases/conformance/node/allowJs/subfolder/index.js(2,11): error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +tests/cases/conformance/node/allowJs/subfolder/index.js(4,5): error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. + + +==== tests/cases/conformance/node/allowJs/subfolder/index.js (2 errors) ==== + // cjs format file + const x = await 1; + ~~~~~ +!!! error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. + export {x}; + for await (const y of []) {} + ~~~~~ +!!! error TS1432: Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext', 'system', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +==== tests/cases/conformance/node/allowJs/index.js (0 errors) ==== + // esm format file + const x = await 1; + export {x}; + for await (const y of []) {} +==== tests/cases/conformance/node/allowJs/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module" + } +==== tests/cases/conformance/node/allowJs/subfolder/package.json (0 errors) ==== + { + "type": "commonjs" + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=nodenext).js b/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=nodenext).js new file mode 100644 index 0000000000000..354fe725f0960 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=nodenext).js @@ -0,0 +1,42 @@ +//// [tests/cases/conformance/node/allowJs/nodeModulesAllowJsTopLevelAwait.ts] //// + +//// [index.js] +// cjs format file +const x = await 1; +export {x}; +for await (const y of []) {} +//// [index.js] +// esm format file +const x = await 1; +export {x}; +for await (const y of []) {} +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +// cjs format file +const x = await 1; +exports.x = x; +for await (const y of []) { } +//// [index.js] +// esm format file +const x = await 1; +export { x }; +for await (const y of []) { } + + +//// [index.d.ts] +export const x: 1; +//// [index.d.ts] +export const x: 1; diff --git a/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=nodenext).symbols b/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=nodenext).symbols new file mode 100644 index 0000000000000..09ad69c019c70 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=nodenext).symbols @@ -0,0 +1,22 @@ +=== tests/cases/conformance/node/allowJs/subfolder/index.js === +// cjs format file +const x = await 1; +>x : Symbol(x, Decl(index.js, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.js, 2, 8)) + +for await (const y of []) {} +>y : Symbol(y, Decl(index.js, 3, 16)) + +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +const x = await 1; +>x : Symbol(x, Decl(index.js, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.js, 2, 8)) + +for await (const y of []) {} +>y : Symbol(y, Decl(index.js, 3, 16)) + diff --git a/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=nodenext).types b/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=nodenext).types new file mode 100644 index 0000000000000..b50bdd2c107e5 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJsTopLevelAwait(module=nodenext).types @@ -0,0 +1,28 @@ +=== tests/cases/conformance/node/allowJs/subfolder/index.js === +// cjs format file +const x = await 1; +>x : 1 +>await 1 : 1 +>1 : 1 + +export {x}; +>x : 1 + +for await (const y of []) {} +>y : any +>[] : undefined[] + +=== tests/cases/conformance/node/allowJs/index.js === +// esm format file +const x = await 1; +>x : 1 +>await 1 : 1 +>1 : 1 + +export {x}; +>x : 1 + +for await (const y of []) {} +>y : any +>[] : undefined[] + diff --git a/tests/baselines/reference/nodeModulesDynamicImport(module=node12).js b/tests/baselines/reference/nodeModulesDynamicImport(module=node12).js index 71f2979b2146e..aceeafb8c5965 100644 --- a/tests/baselines/reference/nodeModulesDynamicImport(module=node12).js +++ b/tests/baselines/reference/nodeModulesDynamicImport(module=node12).js @@ -37,3 +37,9 @@ exports.main = main; export async function main() { const { readFile } = await import("fs"); } + + +//// [index.d.ts] +export declare function main(): Promise; +//// [index.d.ts] +export declare function main(): Promise; diff --git a/tests/baselines/reference/nodeModulesDynamicImport(module=nodenext).js b/tests/baselines/reference/nodeModulesDynamicImport(module=nodenext).js index 71f2979b2146e..aceeafb8c5965 100644 --- a/tests/baselines/reference/nodeModulesDynamicImport(module=nodenext).js +++ b/tests/baselines/reference/nodeModulesDynamicImport(module=nodenext).js @@ -37,3 +37,9 @@ exports.main = main; export async function main() { const { readFile } = await import("fs"); } + + +//// [index.d.ts] +export declare function main(): Promise; +//// [index.d.ts] +export declare function main(): Promise; diff --git a/tests/baselines/reference/nodeModulesExportAssignments(module=node12).js b/tests/baselines/reference/nodeModulesExportAssignments(module=node12).js index 687d129e52e4e..2d09438ae7cd8 100644 --- a/tests/baselines/reference/nodeModulesExportAssignments(module=node12).js +++ b/tests/baselines/reference/nodeModulesExportAssignments(module=node12).js @@ -28,3 +28,11 @@ module.exports = a; // esm format file const a = {}; export {}; + + +//// [index.d.ts] +declare const a: {}; +export = a; +//// [index.d.ts] +declare const a: {}; +export = a; diff --git a/tests/baselines/reference/nodeModulesExportAssignments(module=nodenext).js b/tests/baselines/reference/nodeModulesExportAssignments(module=nodenext).js index 687d129e52e4e..2d09438ae7cd8 100644 --- a/tests/baselines/reference/nodeModulesExportAssignments(module=nodenext).js +++ b/tests/baselines/reference/nodeModulesExportAssignments(module=nodenext).js @@ -28,3 +28,11 @@ module.exports = a; // esm format file const a = {}; export {}; + + +//// [index.d.ts] +declare const a: {}; +export = a; +//// [index.d.ts] +declare const a: {}; +export = a; diff --git a/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=node12).js b/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=node12).js index cc5f8296acfc8..064128d216ee8 100644 --- a/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=node12).js +++ b/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=node12).js @@ -46,3 +46,19 @@ class Object { } export const __esModule = false; export { require, exports, Object }; + + +//// [index.d.ts] +declare function require(): void; +declare const exports: {}; +declare class Object { +} +export declare const __esModule = false; +export { require, exports, Object }; +//// [index.d.ts] +declare function require(): void; +declare const exports: {}; +declare class Object { +} +export declare const __esModule = false; +export { require, exports, Object }; diff --git a/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=nodenext).js b/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=nodenext).js index cc5f8296acfc8..064128d216ee8 100644 --- a/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=nodenext).js +++ b/tests/baselines/reference/nodeModulesGeneratedNameCollisions(module=nodenext).js @@ -46,3 +46,19 @@ class Object { } export const __esModule = false; export { require, exports, Object }; + + +//// [index.d.ts] +declare function require(): void; +declare const exports: {}; +declare class Object { +} +export declare const __esModule = false; +export { require, exports, Object }; +//// [index.d.ts] +declare function require(): void; +declare const exports: {}; +declare class Object { +} +export declare const __esModule = false; +export { require, exports, Object }; diff --git a/tests/baselines/reference/nodeModulesImportAssignments(module=node12).js b/tests/baselines/reference/nodeModulesImportAssignments(module=node12).js index 509c046355ebe..c73ff1177a58e 100644 --- a/tests/baselines/reference/nodeModulesImportAssignments(module=node12).js +++ b/tests/baselines/reference/nodeModulesImportAssignments(module=node12).js @@ -55,3 +55,11 @@ const fs = __require_1("fs"); fs.readFile; const fs2 = __require_1("fs"); export { fs2 }; + + +//// [index.d.ts] +export import fs2 = require("fs"); +//// [index.d.ts] +export import fs2 = require("fs"); +//// [file.d.ts] +export import fs2 = require("fs"); diff --git a/tests/baselines/reference/nodeModulesImportAssignments(module=nodenext).js b/tests/baselines/reference/nodeModulesImportAssignments(module=nodenext).js index 509c046355ebe..c73ff1177a58e 100644 --- a/tests/baselines/reference/nodeModulesImportAssignments(module=nodenext).js +++ b/tests/baselines/reference/nodeModulesImportAssignments(module=nodenext).js @@ -55,3 +55,11 @@ const fs = __require_1("fs"); fs.readFile; const fs2 = __require_1("fs"); export { fs2 }; + + +//// [index.d.ts] +export import fs2 = require("fs"); +//// [index.d.ts] +export import fs2 = require("fs"); +//// [file.d.ts] +export import fs2 = require("fs"); diff --git a/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=node12).js b/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=node12).js index 7e7ddefb4008e..87467d9fd7e6b 100644 --- a/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=node12).js +++ b/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=node12).js @@ -44,3 +44,9 @@ import { default as _fs } from "fs"; _fs.readFile; import * as fs from "fs"; fs.readFile; + + +//// [index.d.ts] +export {}; +//// [index.d.ts] +export {}; diff --git a/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=nodenext).js b/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=nodenext).js index 7e7ddefb4008e..87467d9fd7e6b 100644 --- a/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=nodenext).js +++ b/tests/baselines/reference/nodeModulesImportHelpersCollisions(module=nodenext).js @@ -44,3 +44,9 @@ import { default as _fs } from "fs"; _fs.readFile; import * as fs from "fs"; fs.readFile; + + +//// [index.d.ts] +export {}; +//// [index.d.ts] +export {}; diff --git a/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=node12).js b/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=node12).js index 0ba480d137160..1cc268a7fa066 100644 --- a/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=node12).js +++ b/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=node12).js @@ -37,3 +37,11 @@ exports.fs = (0, tslib_1.__importStar)(require("fs")); // esm format file export * from "fs"; export * as fs from "fs"; + + +//// [index.d.ts] +export * from "fs"; +export * as fs from "fs"; +//// [index.d.ts] +export * from "fs"; +export * as fs from "fs"; diff --git a/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=nodenext).js b/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=nodenext).js index 0ba480d137160..1cc268a7fa066 100644 --- a/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=nodenext).js +++ b/tests/baselines/reference/nodeModulesImportHelpersCollisions2(module=nodenext).js @@ -37,3 +37,11 @@ exports.fs = (0, tslib_1.__importStar)(require("fs")); // esm format file export * from "fs"; export * as fs from "fs"; + + +//// [index.d.ts] +export * from "fs"; +export * as fs from "fs"; +//// [index.d.ts] +export * from "fs"; +export * as fs from "fs"; diff --git a/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=node12).js b/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=node12).js index b541d7253fb3d..8abf8ba9adac3 100644 --- a/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=node12).js +++ b/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=node12).js @@ -36,3 +36,9 @@ Object.defineProperty(exports, "default", { enumerable: true, get: function () { //// [index.js] // esm format file export { default } from "fs"; + + +//// [index.d.ts] +export { default } from "fs"; +//// [index.d.ts] +export { default } from "fs"; diff --git a/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=nodenext).js b/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=nodenext).js index b541d7253fb3d..8abf8ba9adac3 100644 --- a/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=nodenext).js +++ b/tests/baselines/reference/nodeModulesImportHelpersCollisions3(module=nodenext).js @@ -36,3 +36,9 @@ Object.defineProperty(exports, "default", { enumerable: true, get: function () { //// [index.js] // esm format file export { default } from "fs"; + + +//// [index.d.ts] +export { default } from "fs"; +//// [index.d.ts] +export { default } from "fs"; diff --git a/tests/baselines/reference/nodeModulesImportMeta(module=node12).js b/tests/baselines/reference/nodeModulesImportMeta(module=node12).js index a236853057399..aa962a90bd346 100644 --- a/tests/baselines/reference/nodeModulesImportMeta(module=node12).js +++ b/tests/baselines/reference/nodeModulesImportMeta(module=node12).js @@ -30,3 +30,11 @@ exports.x = x; // esm format file const x = import.meta.url; export { x }; + + +//// [index.d.ts] +declare const x: string; +export { x }; +//// [index.d.ts] +declare const x: string; +export { x }; diff --git a/tests/baselines/reference/nodeModulesImportMeta(module=nodenext).js b/tests/baselines/reference/nodeModulesImportMeta(module=nodenext).js index a236853057399..aa962a90bd346 100644 --- a/tests/baselines/reference/nodeModulesImportMeta(module=nodenext).js +++ b/tests/baselines/reference/nodeModulesImportMeta(module=nodenext).js @@ -30,3 +30,11 @@ exports.x = x; // esm format file const x = import.meta.url; export { x }; + + +//// [index.d.ts] +declare const x: string; +export { x }; +//// [index.d.ts] +declare const x: string; +export { x }; diff --git a/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=node12).js b/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=node12).js index c37ce0438cba1..7ac63da59146b 100644 --- a/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=node12).js +++ b/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=node12).js @@ -52,3 +52,9 @@ async function f() { (0, index_js_1.h)(); } exports.f = f; + + +//// [index.d.ts] +export declare function h(): Promise; +//// [index.d.ts] +export declare function f(): Promise; diff --git a/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=nodenext).js b/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=nodenext).js index c37ce0438cba1..7ac63da59146b 100644 --- a/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=nodenext).js +++ b/tests/baselines/reference/nodeModulesSynchronousCallErrors(module=nodenext).js @@ -52,3 +52,9 @@ async function f() { (0, index_js_1.h)(); } exports.f = f; + + +//// [index.d.ts] +export declare function h(): Promise; +//// [index.d.ts] +export declare function f(): Promise; diff --git a/tests/baselines/reference/nodeModulesTopLevelAwait(module=node12).js b/tests/baselines/reference/nodeModulesTopLevelAwait(module=node12).js index ee36688fe4cf3..8d33777f0c4e7 100644 --- a/tests/baselines/reference/nodeModulesTopLevelAwait(module=node12).js +++ b/tests/baselines/reference/nodeModulesTopLevelAwait(module=node12).js @@ -34,3 +34,11 @@ for await (const y of []) { } const x = await 1; export { x }; for await (const y of []) { } + + +//// [index.d.ts] +declare const x = 1; +export { x }; +//// [index.d.ts] +declare const x = 1; +export { x }; diff --git a/tests/baselines/reference/nodeModulesTopLevelAwait(module=nodenext).js b/tests/baselines/reference/nodeModulesTopLevelAwait(module=nodenext).js index ee36688fe4cf3..8d33777f0c4e7 100644 --- a/tests/baselines/reference/nodeModulesTopLevelAwait(module=nodenext).js +++ b/tests/baselines/reference/nodeModulesTopLevelAwait(module=nodenext).js @@ -34,3 +34,11 @@ for await (const y of []) { } const x = await 1; export { x }; for await (const y of []) { } + + +//// [index.d.ts] +declare const x = 1; +export { x }; +//// [index.d.ts] +declare const x = 1; +export { x }; diff --git a/tests/cases/conformance/node/allowJs/nodeModulesAllowJs1.ts b/tests/cases/conformance/node/allowJs/nodeModulesAllowJs1.ts new file mode 100644 index 0000000000000..9b27ee95c1789 --- /dev/null +++ b/tests/cases/conformance/node/allowJs/nodeModulesAllowJs1.ts @@ -0,0 +1,38 @@ +// @module: node12,nodenext +// @declaration: true +// @allowJs: true +// @checkJs: true +// @outDir: out +// @filename: subfolder/index.js +// cjs format file +const x = 1; +export {x}; +// @filename: subfolder2/index.js +// cjs format file +const x = 1; +export {x}; +// @filename: subfolder2/another/index.js +// esm format file +const x = 1; +export {x}; +// @filename: index.js +// esm format file +const x = 1; +export {x}; +// @filename: package.json +{ + "name": "package", + "private": true, + "type": "module" +} +// @filename: subfolder/package.json +{ + "type": "commonjs" +} +// @filename: subfolder2/package.json +{ +} +// @filename: subfolder2/another/package.json +{ + "type": "module" +} \ No newline at end of file diff --git a/tests/cases/conformance/node/allowJs/nodeModulesAllowJsDynamicImport.ts b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsDynamicImport.ts new file mode 100644 index 0000000000000..d7032c648b46c --- /dev/null +++ b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsDynamicImport.ts @@ -0,0 +1,27 @@ +// @module: node12,nodenext +// @declaration: true +// @allowJs: true +// @checkJs: true +// @outDir: out +// @filename: subfolder/index.js +// cjs format file +export async function main() { + const { readFile } = await import("fs"); +} +// @filename: index.js +// esm format file +export async function main() { + const { readFile } = await import("fs"); +} +// @filename: package.json +{ + "name": "package", + "private": true, + "type": "module" +} +// @filename: subfolder/package.json +{ + "type": "commonjs" +} +// @filename: types.d.ts +declare module "fs"; \ No newline at end of file diff --git a/tests/cases/conformance/node/allowJs/nodeModulesAllowJsExportAssignment.ts b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsExportAssignment.ts new file mode 100644 index 0000000000000..f7d5aaf822a30 --- /dev/null +++ b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsExportAssignment.ts @@ -0,0 +1,32 @@ +// @module: node12,nodenext +// @declaration: true +// @allowJs: true +// @checkJs: true +// @outDir: out +// @filename: subfolder/index.js +// cjs format file +const a = {}; +export = a; +// @filename: subfolder/file.js +// cjs format file +const a = {}; +module.exports = a; +// @filename: index.js +// esm format file +const a = {}; +export = a; +// @filename: file.js +// esm format file +import "fs"; +const a = {}; +module.exports = a; +// @filename: package.json +{ + "name": "package", + "private": true, + "type": "module" +} +// @filename: subfolder/package.json +{ + "type": "commonjs" +} \ No newline at end of file diff --git a/tests/cases/conformance/node/allowJs/nodeModulesAllowJsGeneratedNameCollisions.ts b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsGeneratedNameCollisions.ts new file mode 100644 index 0000000000000..14783731bf9a2 --- /dev/null +++ b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsGeneratedNameCollisions.ts @@ -0,0 +1,29 @@ +// @module: node12,nodenext +// @declaration: true +// @allowJs: true +// @checkJs: true +// @outDir: out +// @filename: subfolder/index.js +// cjs format file +function require() {} +const exports = {}; +class Object {} +export const __esModule = false; +export {require, exports, Object}; +// @filename: index.js +// esm format file +function require() {} +const exports = {}; +class Object {} +export const __esModule = false; +export {require, exports, Object}; +// @filename: package.json +{ + "name": "package", + "private": true, + "type": "module" +} +// @filename: subfolder/package.json +{ + "type": "commonjs" +} \ No newline at end of file diff --git a/tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportAssignment.ts b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportAssignment.ts new file mode 100644 index 0000000000000..53e6b9445002b --- /dev/null +++ b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportAssignment.ts @@ -0,0 +1,34 @@ +// @module: node12,nodenext +// @declaration: true +// @allowJs: true +// @checkJs: true +// @outDir: out +// @filename: subfolder/index.js +// cjs format file +import fs = require("fs"); +fs.readFile; +export import fs2 = require("fs"); +// @filename: index.js +// esm format file +import fs = require("fs"); +fs.readFile; +export import fs2 = require("fs"); +// @filename: file.js +// esm format file +const __require = null; +const _createRequire = null; +import fs = require("fs"); +fs.readFile; +export import fs2 = require("fs"); +// @filename: package.json +{ + "name": "package", + "private": true, + "type": "module" +} +// @filename: subfolder/package.json +{ + "type": "commonjs" +} +// @filename: types.d.ts +declare module "fs"; \ No newline at end of file diff --git a/tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportHelpersCollisions1.ts b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportHelpersCollisions1.ts new file mode 100644 index 0000000000000..d5727a3dc787e --- /dev/null +++ b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportHelpersCollisions1.ts @@ -0,0 +1,34 @@ +// @module: node12,nodenext +// @declaration: true +// @importHelpers: true +// @allowJs: true +// @checkJs: true +// @outDir: out +// @filename: subfolder/index.js +// cjs format file +import {default as _fs} from "fs"; +_fs.readFile; +import * as fs from "fs"; +fs.readFile; +// @filename: index.js +// esm format file +import {default as _fs} from "fs"; +_fs.readFile; +import * as fs from "fs"; +fs.readFile; +// @filename: package.json +{ + "name": "package", + "private": true, + "type": "module" +} +// @filename: subfolder/package.json +{ + "type": "commonjs" +} +// @filename: types.d.ts +declare module "fs"; +declare module "tslib" { + export {}; + // intentionally missing all helpers +} \ No newline at end of file diff --git a/tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportHelpersCollisions2.ts b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportHelpersCollisions2.ts new file mode 100644 index 0000000000000..032290f78bafd --- /dev/null +++ b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportHelpersCollisions2.ts @@ -0,0 +1,30 @@ +// @module: node12,nodenext +// @declaration: true +// @importHelpers: true +// @allowJs: true +// @checkJs: true +// @outDir: out +// @filename: subfolder/index.ts +// cjs format file +export * from "fs"; +export * as fs from "fs"; +// @filename: index.js +// esm format file +export * from "fs"; +export * as fs from "fs"; +// @filename: package.json +{ + "name": "package", + "private": true, + "type": "module" +} +// @filename: subfolder/package.json +{ + "type": "commonjs" +} +// @filename: types.d.ts +declare module "fs"; +declare module "tslib" { + export {}; + // intentionally missing all helpers +} \ No newline at end of file diff --git a/tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportHelpersCollisions3.ts b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportHelpersCollisions3.ts new file mode 100644 index 0000000000000..9452e2003a66c --- /dev/null +++ b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportHelpersCollisions3.ts @@ -0,0 +1,32 @@ +// @module: node12,nodenext +// @declaration: true +// @importHelpers: true +// @allowJs: true +// @checkJs: true +// @outDir: out +// @filename: subfolder/index.js +// cjs format file +export {default} from "fs"; +export {default as foo} from "fs"; +export {bar as baz} from "fs"; +// @filename: index.js +// esm format file +export {default} from "fs"; +export {default as foo} from "fs"; +export {bar as baz} from "fs"; +// @filename: package.json +{ + "name": "package", + "private": true, + "type": "module" +} +// @filename: subfolder/package.json +{ + "type": "commonjs" +} +// @filename: types.d.ts +declare module "fs"; +declare module "tslib" { + export {}; + // intentionally missing all helpers +} \ No newline at end of file diff --git a/tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportMeta.ts b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportMeta.ts new file mode 100644 index 0000000000000..a8708434b93ae --- /dev/null +++ b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsImportMeta.ts @@ -0,0 +1,23 @@ +// @module: node12,nodenext +// @declaration: true +// @allowJs: true +// @checkJs: true +// @outDir: out +// @filename: subfolder/index.js +// cjs format file +const x = import.meta.url; +export {x}; +// @filename: index.js +// esm format file +const x = import.meta.url; +export {x}; +// @filename: package.json +{ + "name": "package", + "private": true, + "type": "module" +} +// @filename: subfolder/package.json +{ + "type": "commonjs" +} \ No newline at end of file diff --git a/tests/cases/conformance/node/allowJs/nodeModulesAllowJsSynchronousCallErrors.ts b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsSynchronousCallErrors.ts new file mode 100644 index 0000000000000..15892edbe32c5 --- /dev/null +++ b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsSynchronousCallErrors.ts @@ -0,0 +1,37 @@ +// @module: node12,nodenext +// @declaration: true +// @allowJs: true +// @checkJs: true +// @outDir: out +// @filename: subfolder/index.js +// cjs format file +import {h} from "../index.js"; +import mod = require("../index.js"); +import {f as _f} from "./index.js"; +import mod2 = require("./index.js"); +export async function f() { + const mod3 = await import ("../index.js"); + const mod4 = await import ("./index.js"); + h(); +} +// @filename: index.js +// esm format file +import {h as _h} from "./index.js"; +import mod = require("./index.js"); +import {f} from "./subfolder/index.js"; +import mod2 = require("./subfolder/index.js"); +export async function h() { + const mod3 = await import ("./index.js"); + const mod4 = await import ("./subfolder/index.js"); + f(); +} +// @filename: package.json +{ + "name": "package", + "private": true, + "type": "module" +} +// @filename: subfolder/package.json +{ + "type": "commonjs" +} \ No newline at end of file diff --git a/tests/cases/conformance/node/allowJs/nodeModulesAllowJsTopLevelAwait.ts b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsTopLevelAwait.ts new file mode 100644 index 0000000000000..872cad71c91d5 --- /dev/null +++ b/tests/cases/conformance/node/allowJs/nodeModulesAllowJsTopLevelAwait.ts @@ -0,0 +1,25 @@ +// @module: node12,nodenext +// @declaration: true +// @allowJs: true +// @checkJs: true +// @outDir: out +// @filename: subfolder/index.js +// cjs format file +const x = await 1; +export {x}; +for await (const y of []) {} +// @filename: index.js +// esm format file +const x = await 1; +export {x}; +for await (const y of []) {} +// @filename: package.json +{ + "name": "package", + "private": true, + "type": "module" +} +// @filename: subfolder/package.json +{ + "type": "commonjs" +} \ No newline at end of file diff --git a/tests/cases/conformance/node/nodeModules1.ts b/tests/cases/conformance/node/nodeModules1.ts index 9d81258595ae8..349d103b0efcf 100644 --- a/tests/cases/conformance/node/nodeModules1.ts +++ b/tests/cases/conformance/node/nodeModules1.ts @@ -1,4 +1,5 @@ // @module: node12,nodenext +// @declaration: true // @filename: subfolder/index.ts // cjs format file const x = 1; diff --git a/tests/cases/conformance/node/nodeModulesDynamicImport.ts b/tests/cases/conformance/node/nodeModulesDynamicImport.ts index 75a5dcfc88cfb..46b317ca52da7 100644 --- a/tests/cases/conformance/node/nodeModulesDynamicImport.ts +++ b/tests/cases/conformance/node/nodeModulesDynamicImport.ts @@ -1,4 +1,5 @@ // @module: node12,nodenext +// @declaration: true // @filename: subfolder/index.ts // cjs format file export async function main() { diff --git a/tests/cases/conformance/node/nodeModulesExportAssignments.ts b/tests/cases/conformance/node/nodeModulesExportAssignments.ts index ba604d85090ac..7cbcd200d9699 100644 --- a/tests/cases/conformance/node/nodeModulesExportAssignments.ts +++ b/tests/cases/conformance/node/nodeModulesExportAssignments.ts @@ -1,4 +1,5 @@ // @module: node12,nodenext +// @declaration: true // @filename: subfolder/index.ts // cjs format file const a = {}; diff --git a/tests/cases/conformance/node/nodeModulesGeneratedNameCollisions.ts b/tests/cases/conformance/node/nodeModulesGeneratedNameCollisions.ts index 5f708e1454c7b..e9a9b9d9eddc3 100644 --- a/tests/cases/conformance/node/nodeModulesGeneratedNameCollisions.ts +++ b/tests/cases/conformance/node/nodeModulesGeneratedNameCollisions.ts @@ -1,4 +1,5 @@ // @module: node12,nodenext +// @declaration: true // @filename: subfolder/index.ts // cjs format file function require() {} diff --git a/tests/cases/conformance/node/nodeModulesImportAssignments.ts b/tests/cases/conformance/node/nodeModulesImportAssignments.ts index d89c23438256a..6c22fe83e000d 100644 --- a/tests/cases/conformance/node/nodeModulesImportAssignments.ts +++ b/tests/cases/conformance/node/nodeModulesImportAssignments.ts @@ -1,4 +1,5 @@ // @module: node12,nodenext +// @declaration: true // @filename: subfolder/index.ts // cjs format file import fs = require("fs"); diff --git a/tests/cases/conformance/node/nodeModulesImportHelpersCollisions.ts b/tests/cases/conformance/node/nodeModulesImportHelpersCollisions.ts index 95f3830e818fa..103b58371243f 100644 --- a/tests/cases/conformance/node/nodeModulesImportHelpersCollisions.ts +++ b/tests/cases/conformance/node/nodeModulesImportHelpersCollisions.ts @@ -1,4 +1,5 @@ // @module: node12,nodenext +// @declaration: true // @importHelpers: true // @filename: subfolder/index.ts // cjs format file diff --git a/tests/cases/conformance/node/nodeModulesImportHelpersCollisions2.ts b/tests/cases/conformance/node/nodeModulesImportHelpersCollisions2.ts index f018d86e63848..7f90947a5fbcf 100644 --- a/tests/cases/conformance/node/nodeModulesImportHelpersCollisions2.ts +++ b/tests/cases/conformance/node/nodeModulesImportHelpersCollisions2.ts @@ -1,4 +1,5 @@ // @module: node12,nodenext +// @declaration: true // @importHelpers: true // @filename: subfolder/index.ts // cjs format file diff --git a/tests/cases/conformance/node/nodeModulesImportHelpersCollisions3.ts b/tests/cases/conformance/node/nodeModulesImportHelpersCollisions3.ts index b661affe17a2c..5f6984ad1fb8b 100644 --- a/tests/cases/conformance/node/nodeModulesImportHelpersCollisions3.ts +++ b/tests/cases/conformance/node/nodeModulesImportHelpersCollisions3.ts @@ -1,4 +1,5 @@ // @module: node12,nodenext +// @declaration: true // @importHelpers: true // @filename: subfolder/index.ts // cjs format file diff --git a/tests/cases/conformance/node/nodeModulesImportMeta.ts b/tests/cases/conformance/node/nodeModulesImportMeta.ts index ea83d1b33b3b3..d684c7b5cb26b 100644 --- a/tests/cases/conformance/node/nodeModulesImportMeta.ts +++ b/tests/cases/conformance/node/nodeModulesImportMeta.ts @@ -1,4 +1,5 @@ // @module: node12,nodenext +// @declaration: true // @filename: subfolder/index.ts // cjs format file const x = import.meta.url; diff --git a/tests/cases/conformance/node/nodeModulesSynchronousCallErrors.ts b/tests/cases/conformance/node/nodeModulesSynchronousCallErrors.ts index 8505ee4775096..78aa93ee17c0c 100644 --- a/tests/cases/conformance/node/nodeModulesSynchronousCallErrors.ts +++ b/tests/cases/conformance/node/nodeModulesSynchronousCallErrors.ts @@ -1,4 +1,5 @@ // @module: node12,nodenext +// @declaration: true // @filename: subfolder/index.ts // cjs format file import {h} from "../index.js"; diff --git a/tests/cases/conformance/node/nodeModulesTopLevelAwait.ts b/tests/cases/conformance/node/nodeModulesTopLevelAwait.ts index 4c950c0072f1d..2fbd5d3b0cd28 100644 --- a/tests/cases/conformance/node/nodeModulesTopLevelAwait.ts +++ b/tests/cases/conformance/node/nodeModulesTopLevelAwait.ts @@ -1,4 +1,5 @@ // @module: node12,nodenext +// @declaration: true // @filename: subfolder/index.ts // cjs format file const x = await 1; From b447ed7707ee780517da4c7d0168e55f88625e90 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Mon, 12 Jul 2021 15:34:43 -0700 Subject: [PATCH 3/9] Fix typos --- src/compiler/program.ts | 2 +- src/compiler/transformers/module/esnextAnd2015.ts | 2 +- src/compiler/types.ts | 4 ++-- tests/baselines/reference/api/tsserverlibrary.d.ts | 4 ++-- tests/baselines/reference/api/typescript.d.ts | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index d52b9bec5da7a..d529b73ffacb5 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -743,7 +743,7 @@ namespace ts { * `options` parameter. * * @param fileName The normalized absolute path to check the format of (it need not exist on disk) - * @param packageJsonInfoCache (Optional) A cache for package file lookups - it's best to have a cache when this function is called often + * @param [packageJsonInfoCache] A cache for package file lookups - it's best to have a cache when this function is called often * @param host The ModuleResolutionHost which can perform the filesystem lookups for package json data * @param options The compiler options to perform the analysis under - relevant options are `moduleResolution` and `traceResolution` * @returns `undefined` if the path has no relevant implied format, `ModuleKind.ESNext` for esm format, and `ModuleKind.CommonJS` for cjs format diff --git a/src/compiler/transformers/module/esnextAnd2015.ts b/src/compiler/transformers/module/esnextAnd2015.ts index a4e75b84c8b7f..fa4532d143255 100644 --- a/src/compiler/transformers/module/esnextAnd2015.ts +++ b/src/compiler/transformers/module/esnextAnd2015.ts @@ -86,7 +86,7 @@ namespace ts { /** * Creates a `require()` call to import an external module. * - * @param importNode The declararation to import. + * @param importNode The declaration to import. */ function createRequireCall(importNode: ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration) { const moduleName = getExternalModuleNameLiteral(factory, importNode, Debug.checkDefined(currentSourceFile), host, resolver, compilerOptions); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index e101c6614e183..e3a10b9766ff6 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3549,7 +3549,7 @@ namespace ts { languageVersion: ScriptTarget; /** - * When `module` is `Node12` or `NodeNext`, this field controls weather the + * When `module` is `Node12` or `NodeNext`, this field controls whether the * source file in question is an ESNext-output-format file, or a CommonJS-output-format * module. This is derived by the module resolver as it looks up the file, since * it is derived from either the file extension of the module, or the containing @@ -5931,7 +5931,7 @@ namespace ts { NodeJs = 2, // Starting with node12, node's module resolver has significant departures from tranditional cjs resolution // to better support ecmascript modules and their use within node - more features are still being added, so - // we can expect it co change over time, and as such, offer both a `NodeNext` moving resolution target, and a `Node12` + // we can expect it to change over time, and as such, offer both a `NodeNext` moving resolution target, and a `Node12` // version-anchored resolution target Node12 = 3, NodeNext = 99, // Not simply `Node12` so that compiled code linked against TS can use the `Next` value reliably (same as with `ModuleKind`) diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 51398e9b34d45..60094a7eda360 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -1990,7 +1990,7 @@ declare namespace ts { hasNoDefaultLib: boolean; languageVersion: ScriptTarget; /** - * When `module` is `Node12` or `NodeNext`, this field controls weather the + * When `module` is `Node12` or `NodeNext`, this field controls whether the * source file in question is an ESNext-output-format file, or a CommonJS-output-format * module. This is derived by the module resolver as it looks up the file, since * it is derived from either the file extension of the module, or the containing @@ -4953,7 +4953,7 @@ declare namespace ts { * `options` parameter. * * @param fileName The normalized absolute path to check the format of (it need not exist on disk) - * @param packageJsonInfoCache (Optional) A cache for package file lookups - it's best to have a cache when this function is called often + * @param [packageJsonInfoCache] A cache for package file lookups - it's best to have a cache when this function is called often * @param host The ModuleResolutionHost which can perform the filesystem lookups for package json data * @param options The compiler options to perform the analysis under - relevant options are `moduleResolution` and `traceResolution` * @returns `undefined` if the path has no relevant implied format, `ModuleKind.ESNext` for esm format, and `ModuleKind.CommonJS` for cjs format diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 017e6f61628db..20a47d5baefd0 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -1990,7 +1990,7 @@ declare namespace ts { hasNoDefaultLib: boolean; languageVersion: ScriptTarget; /** - * When `module` is `Node12` or `NodeNext`, this field controls weather the + * When `module` is `Node12` or `NodeNext`, this field controls whether the * source file in question is an ESNext-output-format file, or a CommonJS-output-format * module. This is derived by the module resolver as it looks up the file, since * it is derived from either the file extension of the module, or the containing @@ -4953,7 +4953,7 @@ declare namespace ts { * `options` parameter. * * @param fileName The normalized absolute path to check the format of (it need not exist on disk) - * @param packageJsonInfoCache (Optional) A cache for package file lookups - it's best to have a cache when this function is called often + * @param [packageJsonInfoCache] A cache for package file lookups - it's best to have a cache when this function is called often * @param host The ModuleResolutionHost which can perform the filesystem lookups for package json data * @param options The compiler options to perform the analysis under - relevant options are `moduleResolution` and `traceResolution` * @returns `undefined` if the path has no relevant implied format, `ModuleKind.ESNext` for esm format, and `ModuleKind.CommonJS` for cjs format From 9b83a2ef040f8cdc538011273248bc6bb31e715c Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 6 Jul 2021 12:11:22 -0700 Subject: [PATCH 4/9] cts, mts, cjs, mjs, etc extension support --- src/compiler/builderState.ts | 2 +- src/compiler/checker.ts | 12 + src/compiler/commandLineParser.ts | 45 +- src/compiler/diagnosticMessages.json | 8 + src/compiler/emitter.ts | 34 +- src/compiler/moduleNameResolver.ts | 57 +- src/compiler/moduleSpecifiers.ts | 2 +- src/compiler/program.ts | 11 +- src/compiler/utilities.ts | 107 ++-- src/compiler/watch.ts | 2 + src/compiler/watchUtilities.ts | 2 +- src/executeCommandLine/executeCommandLine.ts | 4 +- src/harness/compilerImpl.ts | 6 +- src/harness/fourslashImpl.ts | 3 +- src/harness/vpathUtil.ts | 2 +- src/server/watchType.ts | 2 - src/services/stringCompletions.ts | 8 +- src/testRunner/unittests/moduleResolution.ts | 10 +- src/testRunner/unittests/programApi.ts | 2 +- .../unittests/tsbuild/moduleResolution.ts | 90 ++++ ...tionEmitInvalidReferenceAllowJs.errors.txt | 4 +- ...sFileCompilationWithMapFileAsJs.errors.txt | 4 +- ...hMapFileAsJsWithInlineSourceMap.errors.txt | 4 +- ...lationWithMapFileAsJsWithOutDir.errors.txt | 4 +- .../nodeModules1(module=node12).errors.txt | 158 ++++++ .../reference/nodeModules1(module=node12).js | 265 ++++++++++ .../nodeModules1(module=node12).symbols | 285 +++++++++- .../nodeModules1(module=node12).types | 325 ++++++++++++ .../nodeModules1(module=nodenext).errors.txt | 158 ++++++ .../nodeModules1(module=nodenext).js | 265 ++++++++++ .../nodeModules1(module=nodenext).symbols | 285 +++++++++- .../nodeModules1(module=nodenext).types | 325 ++++++++++++ ...eModulesAllowJs1(module=node12).errors.txt | 158 ++++++ .../nodeModulesAllowJs1(module=node12).js | 265 ++++++++++ ...nodeModulesAllowJs1(module=node12).symbols | 285 +++++++++- .../nodeModulesAllowJs1(module=node12).types | 325 ++++++++++++ ...odulesAllowJs1(module=nodenext).errors.txt | 158 ++++++ .../nodeModulesAllowJs1(module=nodenext).js | 265 ++++++++++ ...deModulesAllowJs1(module=nodenext).symbols | 285 +++++++++- ...nodeModulesAllowJs1(module=nodenext).types | 325 ++++++++++++ ...esForbidenSyntax(module=node12).errors.txt | 139 +++++ ...odeModulesForbidenSyntax(module=node12).js | 172 +++++++ ...dulesForbidenSyntax(module=node12).symbols | 120 +++++ ...ModulesForbidenSyntax(module=node12).types | 168 ++++++ ...ForbidenSyntax(module=nodenext).errors.txt | 139 +++++ ...eModulesForbidenSyntax(module=nodenext).js | 172 +++++++ ...lesForbidenSyntax(module=nodenext).symbols | 120 +++++ ...dulesForbidenSyntax(module=nodenext).types | 168 ++++++ .../amd/invalidRootFile.errors.txt | 8 +- .../node/invalidRootFile.errors.txt | 8 +- ...t-correctly-with-cts-and-mts-extensions.js | 485 ++++++++++++++++++ .../node/allowJs/nodeModulesAllowJs1.ts | 105 ++++ tests/cases/conformance/node/nodeModules1.ts | 105 ++++ .../node/nodeModulesForbidenSyntax.ts | 67 +++ 54 files changed, 6364 insertions(+), 169 deletions(-) create mode 100644 tests/baselines/reference/nodeModules1(module=node12).errors.txt create mode 100644 tests/baselines/reference/nodeModules1(module=nodenext).errors.txt create mode 100644 tests/baselines/reference/nodeModulesAllowJs1(module=node12).errors.txt create mode 100644 tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).errors.txt create mode 100644 tests/baselines/reference/nodeModulesForbidenSyntax(module=node12).errors.txt create mode 100644 tests/baselines/reference/nodeModulesForbidenSyntax(module=node12).js create mode 100644 tests/baselines/reference/nodeModulesForbidenSyntax(module=node12).symbols create mode 100644 tests/baselines/reference/nodeModulesForbidenSyntax(module=node12).types create mode 100644 tests/baselines/reference/nodeModulesForbidenSyntax(module=nodenext).errors.txt create mode 100644 tests/baselines/reference/nodeModulesForbidenSyntax(module=nodenext).js create mode 100644 tests/baselines/reference/nodeModulesForbidenSyntax(module=nodenext).symbols create mode 100644 tests/baselines/reference/nodeModulesForbidenSyntax(module=nodenext).types create mode 100644 tests/baselines/reference/tsbuild/watchMode/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-cts-and-mts-extensions.js create mode 100644 tests/cases/conformance/node/nodeModulesForbidenSyntax.ts diff --git a/src/compiler/builderState.ts b/src/compiler/builderState.ts index 779924a4c9d3a..f94c2086733a2 100644 --- a/src/compiler/builderState.ts +++ b/src/compiler/builderState.ts @@ -423,7 +423,7 @@ namespace ts { ); const firstDts = firstOrUndefined(emitOutput.outputFiles); if (firstDts) { - Debug.assert(fileExtensionIs(firstDts.name, Extension.Dts), "File extension for signature expected to be dts", () => `Found: ${getAnyExtensionFromPath(firstDts.name)} for ${firstDts.name}:: All output files: ${JSON.stringify(emitOutput.outputFiles.map(f => f.name))}`); + Debug.assert(fileExtensionIsOneOf(firstDts.name, [Extension.Dts, Extension.Dmts, Extension.Dcts]), "File extension for signature expected to be dts", () => `Found: ${getAnyExtensionFromPath(firstDts.name)} for ${firstDts.name}:: All output files: ${JSON.stringify(emitOutput.outputFiles.map(f => f.name))}`); latestSignature = (computeHash || generateDjb2Hash)(firstDts.text); if (exportedModulesMapCache && latestSignature !== prevSignature) { updateExportedModules(sourceFile, emitOutput.exportedModulesFromDeclarationEmit, exportedModulesMapCache); diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 70196b6da2add..9345eb730f71a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -30386,6 +30386,12 @@ namespace ts { } function checkAssertion(node: AssertionExpression) { + if (node.kind === SyntaxKind.TypeAssertionExpression) { + const file = getSourceFileOfNode(node); + if (file && fileExtensionIsOneOf(file.fileName, [Extension.Cts, Extension.Mts])) { + grammarErrorOnNode(node, Diagnostics.This_syntax_is_reserved_in_files_with_this_extension_Use_an_as_expression_instead); + } + } return checkAssertionWorker(node, node.type, node.expression); } @@ -41549,6 +41555,12 @@ namespace ts { return false; } + if (node.typeParameters && !(length(node.typeParameters) > 1 || node.typeParameters.hasTrailingComma || node.typeParameters[0].constraint)) { + if (file && fileExtensionIsOneOf(file.fileName, [Extension.Mts, Extension.Cts])) { + grammarErrorOnNode(node.typeParameters[0], Diagnostics.This_syntax_is_reserved_in_files_with_this_extension_Add_a_trailing_comma_or_explicit_constraint); + } + } + const { equalsGreaterThanToken } = node; const startLine = getLineAndCharacterOfPosition(file, equalsGreaterThanToken.pos).line; const endLine = getLineAndCharacterOfPosition(file, equalsGreaterThanToken.end).line; diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 49a0b71fdbe99..9d13f1db0cbb3 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -3214,7 +3214,7 @@ namespace ts { let jsonOnlyIncludeRegexes: readonly RegExp[] | undefined; if (validatedIncludeSpecs && validatedIncludeSpecs.length > 0) { - for (const file of host.readDirectory(basePath, supportedExtensionsWithJsonIfResolveJsonModule, validatedExcludeSpecs, validatedIncludeSpecs, /*depth*/ undefined)) { + for (const file of host.readDirectory(basePath, flatten(supportedExtensionsWithJsonIfResolveJsonModule), validatedExcludeSpecs, validatedIncludeSpecs, /*depth*/ undefined)) { if (fileExtensionIs(file, Extension.Json)) { // Valid only if *.json specified if (!jsonOnlyIncludeRegexes) { @@ -3439,16 +3439,24 @@ namespace ts { * extension priority. * * @param file The path to the file. - * @param extensionPriority The priority of the extension. - * @param context The expansion context. */ - function hasFileWithHigherPriorityExtension(file: string, literalFiles: ESMap, wildcardFiles: ESMap, extensions: readonly string[], keyMapper: (value: string) => string) { - const extensionPriority = getExtensionPriority(file, extensions); - const adjustedExtensionPriority = adjustExtensionPriority(extensionPriority, extensions); - for (let i = ExtensionPriority.Highest; i < adjustedExtensionPriority; i++) { - const higherPriorityExtension = extensions[i]; - const higherPriorityPath = keyMapper(changeExtension(file, higherPriorityExtension)); + function hasFileWithHigherPriorityExtension(file: string, literalFiles: ESMap, wildcardFiles: ESMap, extensions: readonly string[][], keyMapper: (value: string) => string) { + const extensionGroup = forEach(extensions, group => fileExtensionIsOneOf(file, group) ? group : undefined); + if (!extensionGroup) { + return false; + } + for (const ext of extensionGroup) { + if (fileExtensionIs(file, ext)) { + break; + } + const higherPriorityPath = keyMapper(changeExtension(file, ext)); if (literalFiles.has(higherPriorityPath) || wildcardFiles.has(higherPriorityPath)) { + if (ext === Extension.Dts && (fileExtensionIs(file, Extension.Js) || fileExtensionIs(file, Extension.Jsx))) { + // LEGACY BEHAVIOR: An off-by-one bug somewhere in the extension priority system for wildcard module loading allowed declaration + // files to be loaded alongside their js(x) counterparts. We regard this as generally undesirable, but retain the behavior to + // prevent breakage. + continue; + } return true; } } @@ -3461,15 +3469,18 @@ namespace ts { * already been included. * * @param file The path to the file. - * @param extensionPriority The priority of the extension. - * @param context The expansion context. */ - function removeWildcardFilesWithLowerPriorityExtension(file: string, wildcardFiles: ESMap, extensions: readonly string[], keyMapper: (value: string) => string) { - const extensionPriority = getExtensionPriority(file, extensions); - const nextExtensionPriority = getNextLowestExtensionPriority(extensionPriority, extensions); - for (let i = nextExtensionPriority; i < extensions.length; i++) { - const lowerPriorityExtension = extensions[i]; - const lowerPriorityPath = keyMapper(changeExtension(file, lowerPriorityExtension)); + function removeWildcardFilesWithLowerPriorityExtension(file: string, wildcardFiles: ESMap, extensions: readonly string[][], keyMapper: (value: string) => string) { + const extensionGroup = forEach(extensions, group => fileExtensionIsOneOf(file, group) ? group : undefined); + if (!extensionGroup) { + return; + } + for (let i = extensionGroup.length - 1; i >= 0; i--) { + const ext = extensionGroup[i]; + if (fileExtensionIs(file, ext)) { + break; + } + const lowerPriorityPath = keyMapper(changeExtension(file, ext)); wildcardFiles.delete(lowerPriorityPath); } } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index a199dab5bb579..2c16ea3f137a6 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -5975,6 +5975,14 @@ "category": "Error", "code": 7057 }, + "This syntax is reserved in files with this extension. Use an `as` expression instead.": { + "category": "Error", + "code": 7058 + }, + "This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint.": { + "category": "Error", + "code": 7059 + }, "You cannot rename this element.": { "category": "Error", diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 5667e792b4606..943dd14836e78 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -89,7 +89,7 @@ namespace ts { return getOutputPathsForBundle(options, forceDtsPaths); } else { - const ownOutputFilePath = getOwnEmitOutputFilePath(sourceFile.fileName, host, getOutputExtension(sourceFile, options)); + const ownOutputFilePath = getOwnEmitOutputFilePath(sourceFile.fileName, host, getOutputExtension(sourceFile.fileName, options)); const isJsonFile = isJsonSourceFile(sourceFile); // If json file emits to the same location skip writing it, if emitDeclarationOnly skip writing it const isJsonEmittedToSameLocation = isJsonFile && @@ -106,26 +106,23 @@ namespace ts { return (options.sourceMap && !options.inlineSourceMap) ? jsFilePath + ".map" : undefined; } - // JavaScript files are always LanguageVariant.JSX, as JSX syntax is allowed in .js files also. - // So for JavaScript files, '.jsx' is only emitted if the input was '.jsx', and JsxEmit.Preserve. - // For TypeScript, the only time to emit with a '.jsx' extension, is on JSX input, and JsxEmit.Preserve /* @internal */ - export function getOutputExtension(sourceFile: SourceFile, options: CompilerOptions): Extension { - if (isJsonSourceFile(sourceFile)) { + export function getOutputExtension(fileName: string, options: CompilerOptions): Extension { + if (fileExtensionIs(fileName, Extension.Json)) { return Extension.Json; } if (options.jsx === JsxEmit.Preserve) { - if (isSourceFileJS(sourceFile)) { - if (fileExtensionIs(sourceFile.fileName, Extension.Jsx)) { - return Extension.Jsx; - } - } - else if (sourceFile.languageVariant === LanguageVariant.JSX) { - // TypeScript source file preserving JSX syntax + if (fileExtensionIsOneOf(fileName, [Extension.Jsx, Extension.Tsx])) { return Extension.Jsx; } } + if (fileExtensionIsOneOf(fileName, [Extension.Mts, Extension.Mjs])) { + return Extension.Mjs; + } + if (fileExtensionIsOneOf(fileName, [Extension.Cts, Extension.Cjs])) { + return Extension.Cjs; + } return Extension.Js; } @@ -140,10 +137,9 @@ namespace ts { /* @internal */ export function getOutputDeclarationFileName(inputFileName: string, configFile: ParsedCommandLine, ignoreCase: boolean, getCommonSourceDirectory?: () => string) { - Debug.assert(!fileExtensionIs(inputFileName, Extension.Dts) && !fileExtensionIs(inputFileName, Extension.Json)); return changeExtension( getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.declarationDir || configFile.options.outDir, getCommonSourceDirectory), - Extension.Dts + getDeclarationEmitExtensionForPath(inputFileName) ); } @@ -152,11 +148,7 @@ namespace ts { const isJsonFile = fileExtensionIs(inputFileName, Extension.Json); const outputFileName = changeExtension( getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.outDir, getCommonSourceDirectory), - isJsonFile ? - Extension.Json : - configFile.options.jsx === JsxEmit.Preserve && (fileExtensionIs(inputFileName, Extension.Tsx) || fileExtensionIs(inputFileName, Extension.Jsx)) ? - Extension.Jsx : - Extension.Js + getOutputExtension(inputFileName, configFile.options) ); return !isJsonFile || comparePaths(inputFileName, outputFileName, Debug.checkDefined(configFile.options.configFilePath), ignoreCase) !== Comparison.EqualTo ? outputFileName : @@ -238,7 +230,7 @@ namespace ts { export function getCommonSourceDirectoryOfConfig({ options, fileNames }: ParsedCommandLine, ignoreCase: boolean): string { return getCommonSourceDirectory( options, - () => filter(fileNames, file => !(options.noEmitForJsFiles && fileExtensionIsOneOf(file, supportedJSExtensions)) && !fileExtensionIs(file, Extension.Dts)), + () => filter(fileNames, file => !(options.noEmitForJsFiles && fileExtensionIsOneOf(file, supportedJSExtensionsFlat)) && !fileExtensionIs(file, Extension.Dts)), getDirectoryPath(normalizeSlashes(Debug.checkDefined(options.configFilePath))), createGetCanonicalFileName(!ignoreCase) ); diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index ab5f754e9eeb3..acd31c36b391c 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -1244,11 +1244,12 @@ namespace ts { function loadModuleFromFile(extensions: Extensions, candidate: string, onlyRecordFailures: boolean, state: ModuleResolutionState): PathAndExtension | undefined { if (extensions === Extensions.Json || extensions === Extensions.TSConfig) { const extensionLess = tryRemoveExtension(candidate, Extension.Json); - return (extensionLess === undefined && extensions === Extensions.Json) ? undefined : tryAddingExtensions(extensionLess || candidate, extensions, onlyRecordFailures, state); + const extension = extensionLess ? candidate.substring(extensionLess.length) : ""; + return (extensionLess === undefined && extensions === Extensions.Json) ? undefined : tryAddingExtensions(extensionLess || candidate, extensions, extension, onlyRecordFailures, state); } // First, try adding an extension. An import of "foo" could be matched by a file "foo.ts", or "foo.js" by "foo.js.ts" - const resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, onlyRecordFailures, state); + const resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, "", onlyRecordFailures, state); if (resolvedByAddingExtension) { return resolvedByAddingExtension; } @@ -1257,16 +1258,16 @@ namespace ts { // e.g. "./foo.js" can be matched by "./foo.ts" or "./foo.d.ts" if (hasJSFileExtension(candidate)) { const extensionless = removeFileExtension(candidate); + const extension = candidate.substring(extensionless.length); if (state.traceEnabled) { - const extension = candidate.substring(extensionless.length); trace(state.host, Diagnostics.File_name_0_has_a_1_extension_stripping_it, candidate, extension); } - return tryAddingExtensions(extensionless, extensions, onlyRecordFailures, state); + return tryAddingExtensions(extensionless, extensions, extension, onlyRecordFailures, state); } } /** Try to return an existing file that adds one of the `extensions` to `candidate`. */ - function tryAddingExtensions(candidate: string, extensions: Extensions, onlyRecordFailures: boolean, state: ModuleResolutionState): PathAndExtension | undefined { + function tryAddingExtensions(candidate: string, extensions: Extensions, originalExtension: string, onlyRecordFailures: boolean, state: ModuleResolutionState): PathAndExtension | undefined { if (!onlyRecordFailures) { // check if containing folder exists - if it doesn't then just record failures for all supported extensions without disk probing const directory = getDirectoryPath(candidate); @@ -1277,11 +1278,51 @@ namespace ts { switch (extensions) { case Extensions.DtsOnly: - return tryExtension(Extension.Dts); + switch (originalExtension) { + case Extension.Mjs: + case Extension.Mts: + case Extension.Dmts: + return tryExtension(Extension.Dmts); + case Extension.Cjs: + case Extension.Cts: + case Extension.Dcts: + return tryExtension(Extension.Dcts); + case Extension.Json: + candidate += Extension.Json; + return tryExtension(Extension.Dts); + default: return tryExtension(Extension.Dts); + } case Extensions.TypeScript: - return tryExtension(Extension.Ts) || tryExtension(Extension.Tsx) || tryExtension(Extension.Dts); + switch (originalExtension) { + case Extension.Mjs: + case Extension.Mts: + case Extension.Dmts: + return tryExtension(Extension.Mts) || tryExtension(Extension.Dmts); + case Extension.Cjs: + case Extension.Cts: + case Extension.Dcts: + return tryExtension(Extension.Cts) || tryExtension(Extension.Dcts); + case Extension.Json: + candidate += Extension.Json; + return tryExtension(Extension.Dts); + default: + return tryExtension(Extension.Ts) || tryExtension(Extension.Tsx) || tryExtension(Extension.Dts); + } case Extensions.JavaScript: - return tryExtension(Extension.Js) || tryExtension(Extension.Jsx); + switch (originalExtension) { + case Extension.Mjs: + case Extension.Mts: + case Extension.Dmts: + return tryExtension(Extension.Mjs); + case Extension.Cjs: + case Extension.Cts: + case Extension.Dcts: + return tryExtension(Extension.Cjs); + case Extension.Json: + return tryExtension(Extension.Json); + default: + return tryExtension(Extension.Js) || tryExtension(Extension.Jsx); + } case Extensions.TSConfig: case Extensions.Json: return tryExtension(Extension.Json); diff --git a/src/compiler/moduleSpecifiers.ts b/src/compiler/moduleSpecifiers.ts index de42460d54aeb..8bfffcffb82ef 100644 --- a/src/compiler/moduleSpecifiers.ts +++ b/src/compiler/moduleSpecifiers.ts @@ -652,7 +652,7 @@ namespace ts.moduleSpecifiers { function tryGetAnyFileFromPath(host: ModuleSpecifierResolutionHost, path: string) { if (!host.fileExists) return; // We check all js, `node` and `json` extensions in addition to TS, since node module resolution would also choose those over the directory - const extensions = getSupportedExtensions({ allowJs: true }, [{ extension: "node", isMixedContent: false }, { extension: "json", isMixedContent: false, scriptKind: ScriptKind.JSON }]); + const extensions = flatten(getSupportedExtensions({ allowJs: true }, [{ extension: "node", isMixedContent: false }, { extension: "json", isMixedContent: false, scriptKind: ScriptKind.JSON }])); for (const e of extensions) { const fullPath = path + e; if (host.fileExists(fullPath)) { diff --git a/src/compiler/program.ts b/src/compiler/program.ts index d529b73ffacb5..f3c3452fee9dd 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -2466,13 +2466,13 @@ namespace ts { if (hasExtension(fileName)) { const canonicalFileName = host.getCanonicalFileName(fileName); - if (!options.allowNonTsExtensions && !forEach(supportedExtensionsWithJsonIfResolveJsonModule, extension => fileExtensionIs(canonicalFileName, extension))) { + if (!options.allowNonTsExtensions && !forEach(flatten(supportedExtensionsWithJsonIfResolveJsonModule), extension => fileExtensionIs(canonicalFileName, extension))) { if (fail) { if (hasJSFileExtension(canonicalFileName)) { fail(Diagnostics.File_0_is_a_JavaScript_file_Did_you_mean_to_enable_the_allowJs_option, fileName); } else { - fail(Diagnostics.File_0_has_an_unsupported_extension_The_only_supported_extensions_are_1, fileName, "'" + supportedExtensions.join("', '") + "'"); + fail(Diagnostics.File_0_has_an_unsupported_extension_The_only_supported_extensions_are_1, fileName, "'" + flatten(supportedExtensions).join("', '") + "'"); } } return undefined; @@ -2504,8 +2504,9 @@ namespace ts { return undefined; } - const sourceFileWithAddedExtension = forEach(supportedExtensions, extension => getSourceFile(fileName + extension)); - if (fail && !sourceFileWithAddedExtension) fail(Diagnostics.Could_not_resolve_the_path_0_with_the_extensions_Colon_1, fileName, "'" + supportedExtensions.join("', '") + "'"); + // Only try adding extensions from the first supported group (which should be .ts/.tsx/.d.ts) + const sourceFileWithAddedExtension = forEach(supportedExtensions[0], extension => getSourceFile(fileName + extension)); + if (fail && !sourceFileWithAddedExtension) fail(Diagnostics.Could_not_resolve_the_path_0_with_the_extensions_Colon_1, fileName, "'" + flatten(supportedExtensions).join("', '") + "'"); return sourceFileWithAddedExtension; } } @@ -3704,7 +3705,7 @@ namespace ts { return containsPath(options.outDir, filePath, currentDirectory, !host.useCaseSensitiveFileNames()); } - if (fileExtensionIsOneOf(filePath, supportedJSExtensions) || fileExtensionIs(filePath, Extension.Dts)) { + if (fileExtensionIsOneOf(filePath, supportedJSExtensionsFlat) || fileExtensionIs(filePath, Extension.Dts)) { // Otherwise just check if sourceFile with the name exists const filePathWithoutExtension = removeFileExtension(filePath); return !!getSourceFileByPath((filePathWithoutExtension + Extension.Ts) as Path) || diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index df03bfa8d743d..477fbba6fd016 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -4234,7 +4234,15 @@ namespace ts { const path = outputDir ? getSourceFilePathInNewDirWorker(fileName, outputDir, currentDirectory, commonSourceDirectory, getCanonicalFileName) : fileName; - return removeFileExtension(path) + Extension.Dts; + const declarationExtension = getDeclarationEmitExtensionForPath(path); + return removeFileExtension(path) + declarationExtension; + } + + export function getDeclarationEmitExtensionForPath(path: string) { + return fileExtensionIsOneOf(path, [Extension.Mjs, Extension.Mts]) ? Extension.Dmts : + fileExtensionIsOneOf(path, [Extension.Cjs, Extension.Cts]) ? Extension.Dcts : + fileExtensionIsOneOf(path, [Extension.Json]) ? `.json.d.ts` : // Drive-by redefinition of json declaration file output name so if it's ever enabled, it behaves well + Extension.Dts; } export function outFile(options: CompilerOptions) { @@ -6702,37 +6710,42 @@ namespace ts { /** * List of supported extensions in order of file resolution precedence. */ - export const supportedTSExtensions: readonly Extension[] = [Extension.Ts, Extension.Tsx, Extension.Dts]; - export const supportedTSExtensionsWithJson: readonly Extension[] = [Extension.Ts, Extension.Tsx, Extension.Dts, Extension.Json]; + export const supportedTSExtensions: readonly Extension[][] = [[Extension.Ts, Extension.Tsx, Extension.Dts], [Extension.Cts, Extension.Dcts], [Extension.Mts, Extension.Dmts]]; + export const supportedTSExtensionsFlat: readonly Extension[] = flatten(supportedTSExtensions); + const supportedTSExtensionsWithJson: readonly Extension[][] = [...supportedTSExtensions, [Extension.Json]]; /** Must have ".d.ts" first because if ".ts" goes first, that will be detected as the extension instead of ".d.ts". */ - export const supportedTSExtensionsForExtractExtension: readonly Extension[] = [Extension.Dts, Extension.Ts, Extension.Tsx]; - export const supportedJSExtensions: readonly Extension[] = [Extension.Js, Extension.Jsx]; - export const supportedJSAndJsonExtensions: readonly Extension[] = [Extension.Js, Extension.Jsx, Extension.Json]; - const allSupportedExtensions: readonly Extension[] = [...supportedTSExtensions, ...supportedJSExtensions]; - const allSupportedExtensionsWithJson: readonly Extension[] = [...supportedTSExtensions, ...supportedJSExtensions, Extension.Json]; - - export function getSupportedExtensions(options?: CompilerOptions): readonly Extension[]; - export function getSupportedExtensions(options?: CompilerOptions, extraFileExtensions?: readonly FileExtensionInfo[]): readonly string[]; - export function getSupportedExtensions(options?: CompilerOptions, extraFileExtensions?: readonly FileExtensionInfo[]): readonly string[] { + const supportedTSExtensionsForExtractExtension: readonly Extension[] = [Extension.Dts, Extension.Dcts, Extension.Dmts, Extension.Cts, Extension.Mts, Extension.Ts, Extension.Tsx, Extension.Cts, Extension.Mts]; + export const supportedJSExtensions: readonly Extension[][] = [[Extension.Js, Extension.Jsx], [Extension.Mjs], [Extension.Cjs]]; + export const supportedJSExtensionsFlat: readonly Extension[] = flatten(supportedJSExtensions); + const allSupportedExtensions: readonly Extension[][] = [[Extension.Ts, Extension.Tsx, Extension.Dts, Extension.Js, Extension.Jsx], [Extension.Cts, Extension.Dcts, Extension.Cjs], [Extension.Mts, Extension.Dmts, Extension.Mjs]]; + const allSupportedExtensionsWithJson: readonly Extension[][] = [...allSupportedExtensions, [Extension.Json]]; + + export function getSupportedExtensions(options?: CompilerOptions): readonly Extension[][]; + export function getSupportedExtensions(options?: CompilerOptions, extraFileExtensions?: readonly FileExtensionInfo[]): readonly string[][]; + export function getSupportedExtensions(options?: CompilerOptions, extraFileExtensions?: readonly FileExtensionInfo[]): readonly string[][] { const needJsExtensions = options && getAllowJSCompilerOption(options); if (!extraFileExtensions || extraFileExtensions.length === 0) { return needJsExtensions ? allSupportedExtensions : supportedTSExtensions; } + const builtins = needJsExtensions ? allSupportedExtensions : supportedTSExtensions; + const flatBuiltins = flatten(builtins); const extensions = [ - ...needJsExtensions ? allSupportedExtensions : supportedTSExtensions, - ...mapDefined(extraFileExtensions, x => x.scriptKind === ScriptKind.Deferred || needJsExtensions && isJSLike(x.scriptKind) ? x.extension : undefined) + ...builtins, + ...mapDefined(extraFileExtensions, x => x.scriptKind === ScriptKind.Deferred || needJsExtensions && isJSLike(x.scriptKind) && flatBuiltins.indexOf(x.extension as Extension) === -1 ? [x.extension] : undefined) ]; - return deduplicate(extensions, equateStringsCaseSensitive, compareStringsCaseSensitive); + return extensions; } - export function getSuppoertedExtensionsWithJsonIfResolveJsonModule(options: CompilerOptions | undefined, supportedExtensions: readonly string[]): readonly string[] { + export function getSuppoertedExtensionsWithJsonIfResolveJsonModule(options: CompilerOptions | undefined, supportedExtensions: readonly Extension[][]): readonly Extension[][]; + export function getSuppoertedExtensionsWithJsonIfResolveJsonModule(options: CompilerOptions | undefined, supportedExtensions: readonly string[][]): readonly string[][]; + export function getSuppoertedExtensionsWithJsonIfResolveJsonModule(options: CompilerOptions | undefined, supportedExtensions: readonly string[][]): readonly string[][] { if (!options || !options.resolveJsonModule) { return supportedExtensions; } if (supportedExtensions === allSupportedExtensions) { return allSupportedExtensionsWithJson; } if (supportedExtensions === supportedTSExtensions) { return supportedTSExtensionsWithJson; } - return [...supportedExtensions, Extension.Json]; + return [...supportedExtensions, [Extension.Json]]; } function isJSLike(scriptKind: ScriptKind | undefined): boolean { @@ -6740,18 +6753,18 @@ namespace ts { } export function hasJSFileExtension(fileName: string): boolean { - return some(supportedJSExtensions, extension => fileExtensionIs(fileName, extension)); + return some(supportedJSExtensionsFlat, extension => fileExtensionIs(fileName, extension)); } export function hasTSFileExtension(fileName: string): boolean { - return some(supportedTSExtensions, extension => fileExtensionIs(fileName, extension)); + return some(supportedTSExtensionsFlat, extension => fileExtensionIs(fileName, extension)); } export function isSupportedSourceFileName(fileName: string, compilerOptions?: CompilerOptions, extraFileExtensions?: readonly FileExtensionInfo[]) { if (!fileName) { return false; } const supportedExtensions = getSupportedExtensions(compilerOptions, extraFileExtensions); - for (const extension of getSuppoertedExtensionsWithJsonIfResolveJsonModule(compilerOptions, supportedExtensions)) { + for (const extension of flatten(getSuppoertedExtensionsWithJsonIfResolveJsonModule(compilerOptions, supportedExtensions))) { if (fileExtensionIs(fileName, extension)) { return true; } @@ -6771,59 +6784,7 @@ namespace ts { ); } - /** - * Extension boundaries by priority. Lower numbers indicate higher priorities, and are - * aligned to the offset of the highest priority extension in the - * allSupportedExtensions array. - */ - export const enum ExtensionPriority { - TypeScriptFiles = 0, - DeclarationAndJavaScriptFiles = 2, - - Highest = TypeScriptFiles, - Lowest = DeclarationAndJavaScriptFiles, - } - - export function getExtensionPriority(path: string, supportedExtensions: readonly string[]): ExtensionPriority { - for (let i = supportedExtensions.length - 1; i >= 0; i--) { - if (fileExtensionIs(path, supportedExtensions[i])) { - return adjustExtensionPriority(i as ExtensionPriority, supportedExtensions); - } - } - - // If its not in the list of supported extensions, this is likely a - // TypeScript file with a non-ts extension - return ExtensionPriority.Highest; - } - - /** - * Adjusts an extension priority to be the highest priority within the same range. - */ - export function adjustExtensionPriority(extensionPriority: ExtensionPriority, supportedExtensions: readonly string[]): ExtensionPriority { - if (extensionPriority < ExtensionPriority.DeclarationAndJavaScriptFiles) { - return ExtensionPriority.TypeScriptFiles; - } - else if (extensionPriority < supportedExtensions.length) { - return ExtensionPriority.DeclarationAndJavaScriptFiles; - } - else { - return supportedExtensions.length; - } - } - - /** - * Gets the next lowest extension priority for a given priority. - */ - export function getNextLowestExtensionPriority(extensionPriority: ExtensionPriority, supportedExtensions: readonly string[]): ExtensionPriority { - if (extensionPriority < ExtensionPriority.DeclarationAndJavaScriptFiles) { - return ExtensionPriority.DeclarationAndJavaScriptFiles; - } - else { - return supportedExtensions.length; - } - } - - const extensionsToRemove = [Extension.Dts, Extension.Ts, Extension.Js, Extension.Tsx, Extension.Jsx, Extension.Json]; + const extensionsToRemove = [Extension.Dts, Extension.Dmts, Extension.Dcts, Extension.Mjs, Extension.Mts, Extension.Cjs, Extension.Cts, Extension.Ts, Extension.Js, Extension.Tsx, Extension.Jsx, Extension.Json]; export function removeFileExtension(path: string): string { for (const ext of extensionsToRemove) { const extensionless = tryRemoveExtension(path, ext); diff --git a/src/compiler/watch.ts b/src/compiler/watch.ts index d444e63c800c9..d3a44d9231a83 100644 --- a/src/compiler/watch.ts +++ b/src/compiler/watch.ts @@ -418,6 +418,7 @@ namespace ts { ConfigFileOfReferencedProject: "Config file of referened project", ExtendedConfigOfReferencedProject: "Extended config file of referenced project", WildcardDirectoryOfReferencedProject: "Wild card directory of referenced project", + PackageJsonFile: "package.json file for import suggestions", }; export interface WatchTypeRegistry { @@ -431,6 +432,7 @@ namespace ts { ConfigFileOfReferencedProject: "Config file of referened project", ExtendedConfigOfReferencedProject: "Extended config file of referenced project", WildcardDirectoryOfReferencedProject: "Wild card directory of referenced project", + PackageJsonFile: "package.json file for import suggestions", } interface WatchFactory extends ts.WatchFactory { diff --git a/src/compiler/watchUtilities.ts b/src/compiler/watchUtilities.ts index 39256b39acb68..7e13212596323 100644 --- a/src/compiler/watchUtilities.ts +++ b/src/compiler/watchUtilities.ts @@ -480,7 +480,7 @@ namespace ts { // If its declaration directory: its not ignored if not excluded by config if (options.declarationDir) return false; } - else if (!fileExtensionIsOneOf(fileOrDirectoryPath, supportedJSExtensions)) { + else if (!fileExtensionIsOneOf(fileOrDirectoryPath, supportedJSExtensionsFlat)) { return false; } diff --git a/src/executeCommandLine/executeCommandLine.ts b/src/executeCommandLine/executeCommandLine.ts index 888172b87325e..a6979376e3a6f 100644 --- a/src/executeCommandLine/executeCommandLine.ts +++ b/src/executeCommandLine/executeCommandLine.ts @@ -43,10 +43,10 @@ namespace ts { } const path = file.path; - if (fileExtensionIsOneOf(path, supportedTSExtensions)) { + if (fileExtensionIsOneOf(path, supportedTSExtensionsFlat)) { return "TypeScript"; } - else if (fileExtensionIsOneOf(path, supportedJSExtensions)) { + else if (fileExtensionIsOneOf(path, supportedJSExtensionsFlat)) { return "JavaScript"; } else if (fileExtensionIs(path, Extension.Json)) { diff --git a/src/harness/compilerImpl.ts b/src/harness/compilerImpl.ts index 7d42ccea2c0bd..9f7c1503ae8fb 100644 --- a/src/harness/compilerImpl.ts +++ b/src/harness/compilerImpl.ts @@ -118,11 +118,11 @@ namespace compiler { const input = new documents.TextDocument(sourceFile.fileName, sourceFile.text); this._inputs.push(input); if (!vpath.isDeclaration(sourceFile.fileName)) { - const extname = ts.getOutputExtension(sourceFile, this.options); + const extname = ts.getOutputExtension(sourceFile.fileName, this.options); const outputs: CompilationOutput = { inputs: [input], js: js.get(this.getOutputPath(sourceFile.fileName, extname)), - dts: dts.get(this.getOutputPath(sourceFile.fileName, ".d.ts")), + dts: dts.get(this.getOutputPath(sourceFile.fileName, ts.getDeclarationEmitExtensionForPath(sourceFile.fileName))), map: maps.get(this.getOutputPath(sourceFile.fileName, extname + ".map")) }; @@ -205,7 +205,7 @@ namespace compiler { } else { path = vpath.resolve(this.vfs.cwd(), path); - const outDir = ext === ".d.ts" ? this.options.declarationDir || this.options.outDir : this.options.outDir; + const outDir = ext === ".d.ts" || ext === ".json.d.ts" || ext === ".d.mts" || ext === ".d.cts" ? this.options.declarationDir || this.options.outDir : this.options.outDir; if (outDir) { const common = this.commonSourceDirectory; if (common) { diff --git a/src/harness/fourslashImpl.ts b/src/harness/fourslashImpl.ts index af75c48f0bae0..d2953bcd1ad2c 100644 --- a/src/harness/fourslashImpl.ts +++ b/src/harness/fourslashImpl.ts @@ -313,12 +313,13 @@ namespace FourSlash { this.addMatchedInputFile(referenceFilePath, /* extensions */ undefined); }); + const exts = ts.flatten(ts.getSupportedExtensions(compilationOptions)); // Add import files into language-service host ts.forEach(importedFiles, importedFile => { // Fourslash insert tests/cases/fourslash into inputFile.unitName and import statement doesn't require ".ts" // so convert them before making appropriate comparison const importedFilePath = this.basePath + "/" + importedFile.fileName; - this.addMatchedInputFile(importedFilePath, ts.getSupportedExtensions(compilationOptions)); + this.addMatchedInputFile(importedFilePath, exts); }); // Check if no-default-lib flag is false and if so add default library diff --git a/src/harness/vpathUtil.ts b/src/harness/vpathUtil.ts index 31419e976fffb..44ef5b0f6af3f 100644 --- a/src/harness/vpathUtil.ts +++ b/src/harness/vpathUtil.ts @@ -108,7 +108,7 @@ namespace vpath { } export function isDeclaration(path: string) { - return extname(path, ".d.ts", /*ignoreCase*/ false).length > 0; + return ts.fileExtensionIsOneOf(path, [ts.Extension.Dmts, ts.Extension.Dcts, ts.Extension.Dts]); } export function isSourceMap(path: string) { diff --git a/src/server/watchType.ts b/src/server/watchType.ts index 2b9edafb09870..7893de0e26bc1 100644 --- a/src/server/watchType.ts +++ b/src/server/watchType.ts @@ -8,7 +8,6 @@ namespace ts { MissingSourceMapFile: "Missing source map file", NoopConfigFileForInferredRoot: "Noop Config file for the inferred project root", MissingGeneratedFile: "Missing generated file", - PackageJsonFile: "package.json file for import suggestions", NodeModulesForModuleSpecifierCache: "node_modules for module specifier cache invalidation", } WatchType.ClosedScriptInfo = "Closed Script info"; @@ -17,5 +16,4 @@ namespace ts { WatchType.MissingSourceMapFile = "Missing source map file"; WatchType.NoopConfigFileForInferredRoot = "Noop Config file for the inferred project root"; WatchType.MissingGeneratedFile = "Missing generated file"; - WatchType.PackageJsonFile = "package.json file for import suggestions"; } diff --git a/src/services/stringCompletions.ts b/src/services/stringCompletions.ts index 9255898ca7289..944b61b885ebd 100644 --- a/src/services/stringCompletions.ts +++ b/src/services/stringCompletions.ts @@ -330,7 +330,7 @@ namespace ts.Completions.StringCompletions { readonly includeExtensionsOption: IncludeExtensionsOption; } function getExtensionOptions(compilerOptions: CompilerOptions, includeExtensionsOption = IncludeExtensionsOption.Exclude): ExtensionOptions { - return { extensions: getSupportedExtensionsForModuleResolution(compilerOptions), includeExtensionsOption }; + return { extensions: flatten(getSupportedExtensionsForModuleResolution(compilerOptions)), includeExtensionsOption }; } function getCompletionEntriesForRelativeModules(literalValue: string, scriptDirectory: string, compilerOptions: CompilerOptions, host: LanguageServiceHost, scriptPath: Path, preferences: UserPreferences) { const includeExtensions = preferences.importModuleSpecifierEnding === "js" ? IncludeExtensionsOption.ModuleSpecifierCompletion : IncludeExtensionsOption.Exclude; @@ -344,10 +344,10 @@ namespace ts.Completions.StringCompletions { } } - function getSupportedExtensionsForModuleResolution(compilerOptions: CompilerOptions): readonly Extension[] { + function getSupportedExtensionsForModuleResolution(compilerOptions: CompilerOptions): readonly Extension[][] { const extensions = getSupportedExtensions(compilerOptions); - return compilerOptions.resolveJsonModule && getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.NodeJs ? - extensions.concat(Extension.Json) : + return getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.NodeJs ? + getSuppoertedExtensionsWithJsonIfResolveJsonModule(compilerOptions, extensions) : extensions; } diff --git a/src/testRunner/unittests/moduleResolution.ts b/src/testRunner/unittests/moduleResolution.ts index e9f44a9e6bb77..37de920604105 100644 --- a/src/testRunner/unittests/moduleResolution.ts +++ b/src/testRunner/unittests/moduleResolution.ts @@ -81,9 +81,11 @@ namespace ts { } describe("unittests:: moduleResolution:: Node module resolution - relative paths", () => { - + // node module resolution does _not_ implicitly append these extensions to an extensionless path (though will still attempt to load them if explicitly) + const nonImplicitExtensions = [Extension.Mts, Extension.Dmts, Extension.Mjs, Extension.Cts, Extension.Dcts, Extension.Cjs]; + const autoExtensions = filter(supportedTSExtensionsFlat, e => nonImplicitExtensions.indexOf(e) === -1); function testLoadAsFile(containingFileName: string, moduleFileNameNoExt: string, moduleName: string): void { - for (const ext of supportedTSExtensions) { + for (const ext of autoExtensions) { test(ext, /*hasDirectoryExists*/ false); test(ext, /*hasDirectoryExists*/ true); } @@ -96,7 +98,7 @@ namespace ts { const failedLookupLocations: string[] = []; const dir = getDirectoryPath(containingFileName); - for (const e of supportedTSExtensions) { + for (const e of autoExtensions) { if (e === ext) { break; } @@ -137,7 +139,7 @@ namespace ts { const resolution = nodeModuleNameResolver(moduleName, containingFile.name, {}, createModuleResolutionHost(hasDirectoryExists, containingFile, packageJson, moduleFile)); checkResolvedModule(resolution.resolvedModule, createResolvedModule(moduleFile.name)); // expect three failed lookup location - attempt to load module as file with all supported extensions - assert.equal(resolution.failedLookupLocations.length, supportedTSExtensions.length); + assert.equal(resolution.failedLookupLocations.length, supportedTSExtensions[0].length); } } diff --git a/src/testRunner/unittests/programApi.ts b/src/testRunner/unittests/programApi.ts index b71d13e54cd7e..359dff1c03434 100644 --- a/src/testRunner/unittests/programApi.ts +++ b/src/testRunner/unittests/programApi.ts @@ -11,7 +11,7 @@ namespace ts { assert.equal(notFound.length, 0, `Not found ${notFound} in actual: ${missingPaths} expected: ${expected}`); } - describe("unittests:: Program.getMissingFilePaths", () => { + describe("unittests:: programApi:: Program.getMissingFilePaths", () => { const options: CompilerOptions = { noLib: true, diff --git a/src/testRunner/unittests/tsbuild/moduleResolution.ts b/src/testRunner/unittests/tsbuild/moduleResolution.ts index 487f83196c36e..29c14a8552019 100644 --- a/src/testRunner/unittests/tsbuild/moduleResolution.ts +++ b/src/testRunner/unittests/tsbuild/moduleResolution.ts @@ -66,6 +66,96 @@ namespace ts.tscWatch { changes: emptyArray }); + verifyTscWatch({ + scenario: "moduleResolution", + subScenario: `resolves specifier in output declaration file from referenced project correctly with cts and mts extensions`, + sys: () => createWatchedSystem([ + { + path: `${projectRoot}/packages/pkg1/package.json`, + content: JSON.stringify({ + name: "pkg1", + version: "1.0.0", + main: "build/index.js", + type: "module" + }) + }, + { + path: `${projectRoot}/packages/pkg1/index.ts`, + content: Utils.dedent` + import type { TheNum } from 'pkg2' + export const theNum: TheNum = 42;` + }, + { + path: `${projectRoot}/packages/pkg1/tsconfig.json`, + content: JSON.stringify({ + compilerOptions: { + outDir: "build", + module: "node12", + }, + references: [{ path: "../pkg2" }] + }) + }, + { + path: `${projectRoot}/packages/pkg2/const.cts`, + content: `export type TheNum = 42;` + }, + { + path: `${projectRoot}/packages/pkg2/index.ts`, + content: `export type { TheNum } from './const.cjs';` + }, + { + path: `${projectRoot}/packages/pkg2/tsconfig.json`, + content: JSON.stringify({ + compilerOptions: { + composite: true, + outDir: "build", + module: "node12", + } + }) + }, + { + path: `${projectRoot}/packages/pkg2/package.json`, + content: JSON.stringify({ + name: "pkg2", + version: "1.0.0", + main: "build/index.js", + type: "module" + }) + }, + { + path: `${projectRoot}/node_modules/pkg2`, + symLink: `${projectRoot}/packages/pkg2`, + }, + { ...libFile, path: `/a/lib/lib.es2020.full.d.ts` } + ], { currentDirectory: projectRoot }), + commandLineArgs: ["-b", "packages/pkg1", "-w", "--verbose", "--traceResolution"], + changes: [ + { + caption: "reports import errors after change to package file", + change: sys => replaceFileText(sys, `${projectRoot}/packages/pkg1/package.json`, `"module"`, `"commonjs"`), + timeouts: runQueuedTimeoutCallbacks, + }, + { + caption: "removes those errors when a package file is changed back", + change: sys => replaceFileText(sys, `${projectRoot}/packages/pkg1/package.json`, `"commonjs"`, `"module"`), + timeouts: runQueuedTimeoutCallbacks, + }, + { + caption: "reports import errors after change to package file", + change: sys => replaceFileText(sys, `${projectRoot}/packages/pkg1/package.json`, `"module"`, `"commonjs"`), + timeouts: runQueuedTimeoutCallbacks, + }, + { + caption: "removes those errors when a package file is changed to cjs extensions", + change: sys => { + replaceFileText(sys, `${projectRoot}/packages/pkg2/package.json`, `"main": "build/index.js"`, `"main": "build/index.cjs"`); + sys.renameFile(`${projectRoot}/packages/pkg2/index.ts`, `${projectRoot}/packages/pkg2/index.cts`) + }, + timeouts: runQueuedTimeoutCallbacks, + }, + ] + }); + verifyTsc({ scenario: "moduleResolution", subScenario: `type reference resolution uses correct options for different resolution options referenced project`, diff --git a/tests/baselines/reference/declarationEmitInvalidReferenceAllowJs.errors.txt b/tests/baselines/reference/declarationEmitInvalidReferenceAllowJs.errors.txt index 79f9afa5f34cb..c035c443cf289 100644 --- a/tests/baselines/reference/declarationEmitInvalidReferenceAllowJs.errors.txt +++ b/tests/baselines/reference/declarationEmitInvalidReferenceAllowJs.errors.txt @@ -1,9 +1,9 @@ -tests/cases/compiler/declarationEmitInvalidReferenceAllowJs.ts(1,22): error TS6231: Could not resolve the path 'tests/cases/compiler/invalid' with the extensions: '.ts', '.tsx', '.d.ts', '.js', '.jsx'. +tests/cases/compiler/declarationEmitInvalidReferenceAllowJs.ts(1,22): error TS6231: Could not resolve the path 'tests/cases/compiler/invalid' with the extensions: '.ts', '.tsx', '.d.ts', '.js', '.jsx', '.cts', '.d.cts', '.cjs', '.mts', '.d.mts', '.mjs'. ==== tests/cases/compiler/declarationEmitInvalidReferenceAllowJs.ts (1 errors) ==== /// ~~~~~~~ -!!! error TS6231: Could not resolve the path 'tests/cases/compiler/invalid' with the extensions: '.ts', '.tsx', '.d.ts', '.js', '.jsx'. +!!! error TS6231: Could not resolve the path 'tests/cases/compiler/invalid' with the extensions: '.ts', '.tsx', '.d.ts', '.js', '.jsx', '.cts', '.d.cts', '.cjs', '.mts', '.d.mts', '.mjs'. var x = 0; \ No newline at end of file diff --git a/tests/baselines/reference/jsFileCompilationWithMapFileAsJs.errors.txt b/tests/baselines/reference/jsFileCompilationWithMapFileAsJs.errors.txt index 1f078b80a0002..2520eedbc7f64 100644 --- a/tests/baselines/reference/jsFileCompilationWithMapFileAsJs.errors.txt +++ b/tests/baselines/reference/jsFileCompilationWithMapFileAsJs.errors.txt @@ -1,13 +1,13 @@ error TS5055: Cannot write file 'tests/cases/compiler/b.js' because it would overwrite input file. Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. -error TS6054: File 'tests/cases/compiler/b.js.map' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts', '.js', '.jsx'. +error TS6054: File 'tests/cases/compiler/b.js.map' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts', '.js', '.jsx', '.cts', '.d.cts', '.cjs', '.mts', '.d.mts', '.mjs'. The file is in the program because: Root file specified for compilation !!! error TS5055: Cannot write file 'tests/cases/compiler/b.js' because it would overwrite input file. !!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. -!!! error TS6054: File 'tests/cases/compiler/b.js.map' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts', '.js', '.jsx'. +!!! error TS6054: File 'tests/cases/compiler/b.js.map' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts', '.js', '.jsx', '.cts', '.d.cts', '.cjs', '.mts', '.d.mts', '.mjs'. !!! error TS6054: The file is in the program because: !!! error TS6054: Root file specified for compilation ==== tests/cases/compiler/a.ts (0 errors) ==== diff --git a/tests/baselines/reference/jsFileCompilationWithMapFileAsJsWithInlineSourceMap.errors.txt b/tests/baselines/reference/jsFileCompilationWithMapFileAsJsWithInlineSourceMap.errors.txt index 1f078b80a0002..2520eedbc7f64 100644 --- a/tests/baselines/reference/jsFileCompilationWithMapFileAsJsWithInlineSourceMap.errors.txt +++ b/tests/baselines/reference/jsFileCompilationWithMapFileAsJsWithInlineSourceMap.errors.txt @@ -1,13 +1,13 @@ error TS5055: Cannot write file 'tests/cases/compiler/b.js' because it would overwrite input file. Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. -error TS6054: File 'tests/cases/compiler/b.js.map' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts', '.js', '.jsx'. +error TS6054: File 'tests/cases/compiler/b.js.map' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts', '.js', '.jsx', '.cts', '.d.cts', '.cjs', '.mts', '.d.mts', '.mjs'. The file is in the program because: Root file specified for compilation !!! error TS5055: Cannot write file 'tests/cases/compiler/b.js' because it would overwrite input file. !!! error TS5055: Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig. -!!! error TS6054: File 'tests/cases/compiler/b.js.map' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts', '.js', '.jsx'. +!!! error TS6054: File 'tests/cases/compiler/b.js.map' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts', '.js', '.jsx', '.cts', '.d.cts', '.cjs', '.mts', '.d.mts', '.mjs'. !!! error TS6054: The file is in the program because: !!! error TS6054: Root file specified for compilation ==== tests/cases/compiler/a.ts (0 errors) ==== diff --git a/tests/baselines/reference/jsFileCompilationWithMapFileAsJsWithOutDir.errors.txt b/tests/baselines/reference/jsFileCompilationWithMapFileAsJsWithOutDir.errors.txt index 5b421bbfc8642..321ab08822506 100644 --- a/tests/baselines/reference/jsFileCompilationWithMapFileAsJsWithOutDir.errors.txt +++ b/tests/baselines/reference/jsFileCompilationWithMapFileAsJsWithOutDir.errors.txt @@ -1,4 +1,4 @@ -error TS6054: File 'tests/cases/compiler/b.js.map' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts'. +error TS6054: File 'tests/cases/compiler/b.js.map' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts', '.cts', '.d.cts', '.mts', '.d.mts'. The file is in the program because: Root file specified for compilation error TS6504: File 'tests/cases/compiler/b.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? @@ -6,7 +6,7 @@ error TS6504: File 'tests/cases/compiler/b.js' is a JavaScript file. Did you mea Root file specified for compilation -!!! error TS6054: File 'tests/cases/compiler/b.js.map' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts'. +!!! error TS6054: File 'tests/cases/compiler/b.js.map' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts', '.cts', '.d.cts', '.mts', '.d.mts'. !!! error TS6054: The file is in the program because: !!! error TS6054: Root file specified for compilation !!! error TS6504: File 'tests/cases/compiler/b.js' is a JavaScript file. Did you mean to enable the 'allowJs' option? diff --git a/tests/baselines/reference/nodeModules1(module=node12).errors.txt b/tests/baselines/reference/nodeModules1(module=node12).errors.txt new file mode 100644 index 0000000000000..8ee0d921d50d2 --- /dev/null +++ b/tests/baselines/reference/nodeModules1(module=node12).errors.txt @@ -0,0 +1,158 @@ +tests/cases/conformance/node/index.cts(2,21): error TS1435: Module './index.js' 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/index.cts(3,21): error TS1435: Module './index.mjs' 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/index.cts(6,21): error TS1435: Module './subfolder/index.mjs' 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/index.cts(9,21): error TS1435: Module './subfolder2/index.mjs' 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/index.cts(11,22): error TS1435: Module './subfolder2/another/index.js' 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/index.cts(12,22): error TS1435: Module './subfolder2/another/index.mjs' 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/subfolder/index.ts (0 errors) ==== + // cjs format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/subfolder/index.cts (0 errors) ==== + // cjs format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/subfolder/index.mts (0 errors) ==== + // esm format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/subfolder2/index.ts (0 errors) ==== + // cjs format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/subfolder2/index.cts (0 errors) ==== + // cjs format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/subfolder2/index.mts (0 errors) ==== + // esm format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/subfolder2/another/index.ts (0 errors) ==== + // esm format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/subfolder2/another/index.mts (0 errors) ==== + // esm format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/subfolder2/another/index.cts (0 errors) ==== + // cjs format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/index.mts (0 errors) ==== + import * as m1 from "./index.js"; + import * as m2 from "./index.mjs"; + import * as m3 from "./index.cjs"; + import * as m4 from "./subfolder/index.js"; + import * as m5 from "./subfolder/index.mjs"; + import * as m6 from "./subfolder/index.cjs"; + import * as m7 from "./subfolder2/index.js"; + import * as m8 from "./subfolder2/index.mjs"; + import * as m9 from "./subfolder2/index.cjs"; + import * as m10 from "./subfolder2/another/index.js"; + import * as m11 from "./subfolder2/another/index.mjs"; + import * as m12 from "./subfolder2/another/index.cjs"; + void m1; + void m2; + void m3; + void m4; + void m5; + void m6; + void m7; + void m8; + void m9; + void m10; + void m11; + void m12; + // esm format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/index.cts (6 errors) ==== + // ESM-format imports below should issue errors + import * as m1 from "./index.js"; + ~~~~~~~~~~~~ +!!! error TS1435: Module './index.js' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. + import * as m2 from "./index.mjs"; + ~~~~~~~~~~~~~ +!!! error TS1435: Module './index.mjs' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. + import * as m3 from "./index.cjs"; + import * as m4 from "./subfolder/index.js"; + import * as m5 from "./subfolder/index.mjs"; + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1435: Module './subfolder/index.mjs' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. + import * as m6 from "./subfolder/index.cjs"; + import * as m7 from "./subfolder2/index.js"; + import * as m8 from "./subfolder2/index.mjs"; + ~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1435: Module './subfolder2/index.mjs' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. + import * as m9 from "./subfolder2/index.cjs"; + import * as m10 from "./subfolder2/another/index.js"; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1435: Module './subfolder2/another/index.js' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. + import * as m11 from "./subfolder2/another/index.mjs"; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1435: Module './subfolder2/another/index.mjs' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. + import * as m12 from "./subfolder2/another/index.cjs"; + void m1; + void m2; + void m3; + void m4; + void m5; + void m6; + void m7; + void m8; + void m9; + void m10; + void m11; + void m12; + // cjs format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/index.ts (0 errors) ==== + import * as m1 from "./index.js"; + import * as m2 from "./index.mjs"; + import * as m3 from "./index.cjs"; + import * as m4 from "./subfolder/index.js"; + import * as m5 from "./subfolder/index.mjs"; + import * as m6 from "./subfolder/index.cjs"; + import * as m7 from "./subfolder2/index.js"; + import * as m8 from "./subfolder2/index.mjs"; + import * as m9 from "./subfolder2/index.cjs"; + import * as m10 from "./subfolder2/another/index.js"; + import * as m11 from "./subfolder2/another/index.mjs"; + import * as m12 from "./subfolder2/another/index.cjs"; + void m1; + void m2; + void m3; + void m4; + void m5; + void m6; + void m7; + void m8; + void m9; + void m10; + void m11; + void m12; + // esm format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module" + } +==== tests/cases/conformance/node/subfolder/package.json (0 errors) ==== + { + "type": "commonjs" + } +==== tests/cases/conformance/node/subfolder2/package.json (0 errors) ==== + { + } +==== tests/cases/conformance/node/subfolder2/another/package.json (0 errors) ==== + { + "type": "module" + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModules1(module=node12).js b/tests/baselines/reference/nodeModules1(module=node12).js index 1acae5c9aab3b..fba5f41f193e3 100644 --- a/tests/baselines/reference/nodeModules1(module=node12).js +++ b/tests/baselines/reference/nodeModules1(module=node12).js @@ -4,15 +4,120 @@ // cjs format file const x = 1; export {x}; +//// [index.cts] +// cjs format file +const x = 1; +export {x}; +//// [index.mts] +// esm format file +const x = 1; +export {x}; //// [index.ts] // cjs format file const x = 1; export {x}; +//// [index.cts] +// cjs format file +const x = 1; +export {x}; +//// [index.mts] +// esm format file +const x = 1; +export {x}; //// [index.ts] // esm format file const x = 1; export {x}; +//// [index.mts] +// esm format file +const x = 1; +export {x}; +//// [index.cts] +// cjs format file +const x = 1; +export {x}; +//// [index.mts] +import * as m1 from "./index.js"; +import * as m2 from "./index.mjs"; +import * as m3 from "./index.cjs"; +import * as m4 from "./subfolder/index.js"; +import * as m5 from "./subfolder/index.mjs"; +import * as m6 from "./subfolder/index.cjs"; +import * as m7 from "./subfolder2/index.js"; +import * as m8 from "./subfolder2/index.mjs"; +import * as m9 from "./subfolder2/index.cjs"; +import * as m10 from "./subfolder2/another/index.js"; +import * as m11 from "./subfolder2/another/index.mjs"; +import * as m12 from "./subfolder2/another/index.cjs"; +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; +// esm format file +const x = 1; +export {x}; +//// [index.cts] +// ESM-format imports below should issue errors +import * as m1 from "./index.js"; +import * as m2 from "./index.mjs"; +import * as m3 from "./index.cjs"; +import * as m4 from "./subfolder/index.js"; +import * as m5 from "./subfolder/index.mjs"; +import * as m6 from "./subfolder/index.cjs"; +import * as m7 from "./subfolder2/index.js"; +import * as m8 from "./subfolder2/index.mjs"; +import * as m9 from "./subfolder2/index.cjs"; +import * as m10 from "./subfolder2/another/index.js"; +import * as m11 from "./subfolder2/another/index.mjs"; +import * as m12 from "./subfolder2/another/index.cjs"; +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; +// cjs format file +const x = 1; +export {x}; //// [index.ts] +import * as m1 from "./index.js"; +import * as m2 from "./index.mjs"; +import * as m3 from "./index.cjs"; +import * as m4 from "./subfolder/index.js"; +import * as m5 from "./subfolder/index.mjs"; +import * as m6 from "./subfolder/index.cjs"; +import * as m7 from "./subfolder2/index.js"; +import * as m8 from "./subfolder2/index.mjs"; +import * as m9 from "./subfolder2/index.cjs"; +import * as m10 from "./subfolder2/another/index.js"; +import * as m11 from "./subfolder2/another/index.mjs"; +import * as m12 from "./subfolder2/another/index.cjs"; +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; // esm format file const x = 1; export {x}; @@ -41,6 +146,17 @@ exports.x = void 0; // cjs format file const x = 1; exports.x = x; +//// [index.cjs] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +// cjs format file +const x = 1; +exports.x = x; +//// [index.mjs] +// esm format file +const x = 1; +export { x }; //// [index.js] "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); @@ -48,25 +164,174 @@ exports.x = void 0; // cjs format file const x = 1; exports.x = x; +//// [index.cjs] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +// cjs format file +const x = 1; +exports.x = x; +//// [index.mjs] +// esm format file +const x = 1; +export { x }; //// [index.js] // esm format file const x = 1; export { x }; +//// [index.mjs] +// esm format file +const x = 1; +export { x }; +//// [index.cjs] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +// cjs format file +const x = 1; +exports.x = x; //// [index.js] +import * as m1 from "./index.js"; +import * as m2 from "./index.mjs"; +import * as m3 from "./index.cjs"; +import * as m4 from "./subfolder/index.js"; +import * as m5 from "./subfolder/index.mjs"; +import * as m6 from "./subfolder/index.cjs"; +import * as m7 from "./subfolder2/index.js"; +import * as m8 from "./subfolder2/index.mjs"; +import * as m9 from "./subfolder2/index.cjs"; +import * as m10 from "./subfolder2/another/index.js"; +import * as m11 from "./subfolder2/another/index.mjs"; +import * as m12 from "./subfolder2/another/index.cjs"; +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; // esm format file const x = 1; export { x }; +//// [index.mjs] +import * as m1 from "./index.js"; +import * as m2 from "./index.mjs"; +import * as m3 from "./index.cjs"; +import * as m4 from "./subfolder/index.js"; +import * as m5 from "./subfolder/index.mjs"; +import * as m6 from "./subfolder/index.cjs"; +import * as m7 from "./subfolder2/index.js"; +import * as m8 from "./subfolder2/index.mjs"; +import * as m9 from "./subfolder2/index.cjs"; +import * as m10 from "./subfolder2/another/index.js"; +import * as m11 from "./subfolder2/another/index.mjs"; +import * as m12 from "./subfolder2/another/index.cjs"; +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; +// esm format file +const x = 1; +export { x }; +//// [index.cjs] +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +// ESM-format imports below should issue errors +const m1 = __importStar(require("./index.js")); +const m2 = __importStar(require("./index.mjs")); +const m3 = __importStar(require("./index.cjs")); +const m4 = __importStar(require("./subfolder/index.js")); +const m5 = __importStar(require("./subfolder/index.mjs")); +const m6 = __importStar(require("./subfolder/index.cjs")); +const m7 = __importStar(require("./subfolder2/index.js")); +const m8 = __importStar(require("./subfolder2/index.mjs")); +const m9 = __importStar(require("./subfolder2/index.cjs")); +const m10 = __importStar(require("./subfolder2/another/index.js")); +const m11 = __importStar(require("./subfolder2/another/index.mjs")); +const m12 = __importStar(require("./subfolder2/another/index.cjs")); +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; +// cjs format file +const x = 1; +exports.x = x; //// [index.d.ts] declare const x = 1; export { x }; +//// [index.d.cts] +declare const x = 1; +export { x }; +//// [index.d.mts] +declare const x = 1; +export { x }; //// [index.d.ts] declare const x = 1; export { x }; +//// [index.d.cts] +declare const x = 1; +export { x }; +//// [index.d.mts] +declare const x = 1; +export { x }; //// [index.d.ts] declare const x = 1; export { x }; +//// [index.d.mts] +declare const x = 1; +export { x }; +//// [index.d.cts] +declare const x = 1; +export { x }; //// [index.d.ts] declare const x = 1; export { x }; +//// [index.d.mts] +declare const x = 1; +export { x }; +//// [index.d.cts] +declare const x = 1; +export { x }; diff --git a/tests/baselines/reference/nodeModules1(module=node12).symbols b/tests/baselines/reference/nodeModules1(module=node12).symbols index e1653429c87db..b8caa52c8cfa0 100644 --- a/tests/baselines/reference/nodeModules1(module=node12).symbols +++ b/tests/baselines/reference/nodeModules1(module=node12).symbols @@ -6,6 +6,22 @@ const x = 1; export {x}; >x : Symbol(x, Decl(index.ts, 2, 8)) +=== tests/cases/conformance/node/subfolder/index.cts === +// cjs format file +const x = 1; +>x : Symbol(x, Decl(index.cts, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.cts, 2, 8)) + +=== tests/cases/conformance/node/subfolder/index.mts === +// esm format file +const x = 1; +>x : Symbol(x, Decl(index.mts, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.mts, 2, 8)) + === tests/cases/conformance/node/subfolder2/index.ts === // cjs format file const x = 1; @@ -14,6 +30,22 @@ const x = 1; export {x}; >x : Symbol(x, Decl(index.ts, 2, 8)) +=== tests/cases/conformance/node/subfolder2/index.cts === +// cjs format file +const x = 1; +>x : Symbol(x, Decl(index.cts, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.cts, 2, 8)) + +=== tests/cases/conformance/node/subfolder2/index.mts === +// esm format file +const x = 1; +>x : Symbol(x, Decl(index.mts, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.mts, 2, 8)) + === tests/cases/conformance/node/subfolder2/another/index.ts === // esm format file const x = 1; @@ -22,11 +54,260 @@ const x = 1; export {x}; >x : Symbol(x, Decl(index.ts, 2, 8)) +=== tests/cases/conformance/node/subfolder2/another/index.mts === +// esm format file +const x = 1; +>x : Symbol(x, Decl(index.mts, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.mts, 2, 8)) + +=== tests/cases/conformance/node/subfolder2/another/index.cts === +// cjs format file +const x = 1; +>x : Symbol(x, Decl(index.cts, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.cts, 2, 8)) + +=== tests/cases/conformance/node/index.mts === +import * as m1 from "./index.js"; +>m1 : Symbol(m1, Decl(index.mts, 0, 6)) + +import * as m2 from "./index.mjs"; +>m2 : Symbol(m2, Decl(index.mts, 1, 6)) + +import * as m3 from "./index.cjs"; +>m3 : Symbol(m3, Decl(index.mts, 2, 6)) + +import * as m4 from "./subfolder/index.js"; +>m4 : Symbol(m4, Decl(index.mts, 3, 6)) + +import * as m5 from "./subfolder/index.mjs"; +>m5 : Symbol(m5, Decl(index.mts, 4, 6)) + +import * as m6 from "./subfolder/index.cjs"; +>m6 : Symbol(m6, Decl(index.mts, 5, 6)) + +import * as m7 from "./subfolder2/index.js"; +>m7 : Symbol(m7, Decl(index.mts, 6, 6)) + +import * as m8 from "./subfolder2/index.mjs"; +>m8 : Symbol(m8, Decl(index.mts, 7, 6)) + +import * as m9 from "./subfolder2/index.cjs"; +>m9 : Symbol(m9, Decl(index.mts, 8, 6)) + +import * as m10 from "./subfolder2/another/index.js"; +>m10 : Symbol(m10, Decl(index.mts, 9, 6)) + +import * as m11 from "./subfolder2/another/index.mjs"; +>m11 : Symbol(m11, Decl(index.mts, 10, 6)) + +import * as m12 from "./subfolder2/another/index.cjs"; +>m12 : Symbol(m12, Decl(index.mts, 11, 6)) + +void m1; +>m1 : Symbol(m1, Decl(index.mts, 0, 6)) + +void m2; +>m2 : Symbol(m2, Decl(index.mts, 1, 6)) + +void m3; +>m3 : Symbol(m3, Decl(index.mts, 2, 6)) + +void m4; +>m4 : Symbol(m4, Decl(index.mts, 3, 6)) + +void m5; +>m5 : Symbol(m5, Decl(index.mts, 4, 6)) + +void m6; +>m6 : Symbol(m6, Decl(index.mts, 5, 6)) + +void m7; +>m7 : Symbol(m7, Decl(index.mts, 6, 6)) + +void m8; +>m8 : Symbol(m8, Decl(index.mts, 7, 6)) + +void m9; +>m9 : Symbol(m9, Decl(index.mts, 8, 6)) + +void m10; +>m10 : Symbol(m10, Decl(index.mts, 9, 6)) + +void m11; +>m11 : Symbol(m11, Decl(index.mts, 10, 6)) + +void m12; +>m12 : Symbol(m12, Decl(index.mts, 11, 6)) + +// esm format file +const x = 1; +>x : Symbol(x, Decl(index.mts, 25, 5)) + +export {x}; +>x : Symbol(m2.x, Decl(index.mts, 26, 8)) + +=== tests/cases/conformance/node/index.cts === +// ESM-format imports below should issue errors +import * as m1 from "./index.js"; +>m1 : Symbol(m1, Decl(index.cts, 1, 6)) + +import * as m2 from "./index.mjs"; +>m2 : Symbol(m2, Decl(index.cts, 2, 6)) + +import * as m3 from "./index.cjs"; +>m3 : Symbol(m3, Decl(index.cts, 3, 6)) + +import * as m4 from "./subfolder/index.js"; +>m4 : Symbol(m4, Decl(index.cts, 4, 6)) + +import * as m5 from "./subfolder/index.mjs"; +>m5 : Symbol(m5, Decl(index.cts, 5, 6)) + +import * as m6 from "./subfolder/index.cjs"; +>m6 : Symbol(m6, Decl(index.cts, 6, 6)) + +import * as m7 from "./subfolder2/index.js"; +>m7 : Symbol(m7, Decl(index.cts, 7, 6)) + +import * as m8 from "./subfolder2/index.mjs"; +>m8 : Symbol(m8, Decl(index.cts, 8, 6)) + +import * as m9 from "./subfolder2/index.cjs"; +>m9 : Symbol(m9, Decl(index.cts, 9, 6)) + +import * as m10 from "./subfolder2/another/index.js"; +>m10 : Symbol(m10, Decl(index.cts, 10, 6)) + +import * as m11 from "./subfolder2/another/index.mjs"; +>m11 : Symbol(m11, Decl(index.cts, 11, 6)) + +import * as m12 from "./subfolder2/another/index.cjs"; +>m12 : Symbol(m12, Decl(index.cts, 12, 6)) + +void m1; +>m1 : Symbol(m1, Decl(index.cts, 1, 6)) + +void m2; +>m2 : Symbol(m2, Decl(index.cts, 2, 6)) + +void m3; +>m3 : Symbol(m3, Decl(index.cts, 3, 6)) + +void m4; +>m4 : Symbol(m4, Decl(index.cts, 4, 6)) + +void m5; +>m5 : Symbol(m5, Decl(index.cts, 5, 6)) + +void m6; +>m6 : Symbol(m6, Decl(index.cts, 6, 6)) + +void m7; +>m7 : Symbol(m7, Decl(index.cts, 7, 6)) + +void m8; +>m8 : Symbol(m8, Decl(index.cts, 8, 6)) + +void m9; +>m9 : Symbol(m9, Decl(index.cts, 9, 6)) + +void m10; +>m10 : Symbol(m10, Decl(index.cts, 10, 6)) + +void m11; +>m11 : Symbol(m11, Decl(index.cts, 11, 6)) + +void m12; +>m12 : Symbol(m12, Decl(index.cts, 12, 6)) + +// cjs format file +const x = 1; +>x : Symbol(x, Decl(index.cts, 26, 5)) + +export {x}; +>x : Symbol(m3.x, Decl(index.cts, 27, 8)) + === tests/cases/conformance/node/index.ts === +import * as m1 from "./index.js"; +>m1 : Symbol(m1, Decl(index.ts, 0, 6)) + +import * as m2 from "./index.mjs"; +>m2 : Symbol(m2, Decl(index.ts, 1, 6)) + +import * as m3 from "./index.cjs"; +>m3 : Symbol(m3, Decl(index.ts, 2, 6)) + +import * as m4 from "./subfolder/index.js"; +>m4 : Symbol(m4, Decl(index.ts, 3, 6)) + +import * as m5 from "./subfolder/index.mjs"; +>m5 : Symbol(m5, Decl(index.ts, 4, 6)) + +import * as m6 from "./subfolder/index.cjs"; +>m6 : Symbol(m6, Decl(index.ts, 5, 6)) + +import * as m7 from "./subfolder2/index.js"; +>m7 : Symbol(m7, Decl(index.ts, 6, 6)) + +import * as m8 from "./subfolder2/index.mjs"; +>m8 : Symbol(m8, Decl(index.ts, 7, 6)) + +import * as m9 from "./subfolder2/index.cjs"; +>m9 : Symbol(m9, Decl(index.ts, 8, 6)) + +import * as m10 from "./subfolder2/another/index.js"; +>m10 : Symbol(m10, Decl(index.ts, 9, 6)) + +import * as m11 from "./subfolder2/another/index.mjs"; +>m11 : Symbol(m11, Decl(index.ts, 10, 6)) + +import * as m12 from "./subfolder2/another/index.cjs"; +>m12 : Symbol(m12, Decl(index.ts, 11, 6)) + +void m1; +>m1 : Symbol(m1, Decl(index.ts, 0, 6)) + +void m2; +>m2 : Symbol(m2, Decl(index.ts, 1, 6)) + +void m3; +>m3 : Symbol(m3, Decl(index.ts, 2, 6)) + +void m4; +>m4 : Symbol(m4, Decl(index.ts, 3, 6)) + +void m5; +>m5 : Symbol(m5, Decl(index.ts, 4, 6)) + +void m6; +>m6 : Symbol(m6, Decl(index.ts, 5, 6)) + +void m7; +>m7 : Symbol(m7, Decl(index.ts, 6, 6)) + +void m8; +>m8 : Symbol(m8, Decl(index.ts, 7, 6)) + +void m9; +>m9 : Symbol(m9, Decl(index.ts, 8, 6)) + +void m10; +>m10 : Symbol(m10, Decl(index.ts, 9, 6)) + +void m11; +>m11 : Symbol(m11, Decl(index.ts, 10, 6)) + +void m12; +>m12 : Symbol(m12, Decl(index.ts, 11, 6)) + // esm format file const x = 1; ->x : Symbol(x, Decl(index.ts, 1, 5)) +>x : Symbol(x, Decl(index.ts, 25, 5)) export {x}; ->x : Symbol(x, Decl(index.ts, 2, 8)) +>x : Symbol(m1.x, Decl(index.ts, 26, 8)) diff --git a/tests/baselines/reference/nodeModules1(module=node12).types b/tests/baselines/reference/nodeModules1(module=node12).types index 1c479a5e7bd48..cf878a592d2e9 100644 --- a/tests/baselines/reference/nodeModules1(module=node12).types +++ b/tests/baselines/reference/nodeModules1(module=node12).types @@ -7,6 +7,24 @@ const x = 1; export {x}; >x : 1 +=== tests/cases/conformance/node/subfolder/index.cts === +// cjs format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + +=== tests/cases/conformance/node/subfolder/index.mts === +// esm format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + === tests/cases/conformance/node/subfolder2/index.ts === // cjs format file const x = 1; @@ -16,6 +34,24 @@ const x = 1; export {x}; >x : 1 +=== tests/cases/conformance/node/subfolder2/index.cts === +// cjs format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + +=== tests/cases/conformance/node/subfolder2/index.mts === +// esm format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + === tests/cases/conformance/node/subfolder2/another/index.ts === // esm format file const x = 1; @@ -25,7 +61,296 @@ const x = 1; export {x}; >x : 1 +=== tests/cases/conformance/node/subfolder2/another/index.mts === +// esm format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + +=== tests/cases/conformance/node/subfolder2/another/index.cts === +// cjs format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + +=== tests/cases/conformance/node/index.mts === +import * as m1 from "./index.js"; +>m1 : typeof m1 + +import * as m2 from "./index.mjs"; +>m2 : typeof m2 + +import * as m3 from "./index.cjs"; +>m3 : typeof m3 + +import * as m4 from "./subfolder/index.js"; +>m4 : typeof m4 + +import * as m5 from "./subfolder/index.mjs"; +>m5 : typeof m5 + +import * as m6 from "./subfolder/index.cjs"; +>m6 : typeof m6 + +import * as m7 from "./subfolder2/index.js"; +>m7 : typeof m7 + +import * as m8 from "./subfolder2/index.mjs"; +>m8 : typeof m8 + +import * as m9 from "./subfolder2/index.cjs"; +>m9 : typeof m9 + +import * as m10 from "./subfolder2/another/index.js"; +>m10 : typeof m10 + +import * as m11 from "./subfolder2/another/index.mjs"; +>m11 : typeof m11 + +import * as m12 from "./subfolder2/another/index.cjs"; +>m12 : typeof m12 + +void m1; +>void m1 : undefined +>m1 : typeof m1 + +void m2; +>void m2 : undefined +>m2 : typeof m2 + +void m3; +>void m3 : undefined +>m3 : typeof m3 + +void m4; +>void m4 : undefined +>m4 : typeof m4 + +void m5; +>void m5 : undefined +>m5 : typeof m5 + +void m6; +>void m6 : undefined +>m6 : typeof m6 + +void m7; +>void m7 : undefined +>m7 : typeof m7 + +void m8; +>void m8 : undefined +>m8 : typeof m8 + +void m9; +>void m9 : undefined +>m9 : typeof m9 + +void m10; +>void m10 : undefined +>m10 : typeof m10 + +void m11; +>void m11 : undefined +>m11 : typeof m11 + +void m12; +>void m12 : undefined +>m12 : typeof m12 + +// esm format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + +=== tests/cases/conformance/node/index.cts === +// ESM-format imports below should issue errors +import * as m1 from "./index.js"; +>m1 : typeof m1 + +import * as m2 from "./index.mjs"; +>m2 : typeof m2 + +import * as m3 from "./index.cjs"; +>m3 : typeof m3 + +import * as m4 from "./subfolder/index.js"; +>m4 : typeof m4 + +import * as m5 from "./subfolder/index.mjs"; +>m5 : typeof m5 + +import * as m6 from "./subfolder/index.cjs"; +>m6 : typeof m6 + +import * as m7 from "./subfolder2/index.js"; +>m7 : typeof m7 + +import * as m8 from "./subfolder2/index.mjs"; +>m8 : typeof m8 + +import * as m9 from "./subfolder2/index.cjs"; +>m9 : typeof m9 + +import * as m10 from "./subfolder2/another/index.js"; +>m10 : typeof m10 + +import * as m11 from "./subfolder2/another/index.mjs"; +>m11 : typeof m11 + +import * as m12 from "./subfolder2/another/index.cjs"; +>m12 : typeof m12 + +void m1; +>void m1 : undefined +>m1 : typeof m1 + +void m2; +>void m2 : undefined +>m2 : typeof m2 + +void m3; +>void m3 : undefined +>m3 : typeof m3 + +void m4; +>void m4 : undefined +>m4 : typeof m4 + +void m5; +>void m5 : undefined +>m5 : typeof m5 + +void m6; +>void m6 : undefined +>m6 : typeof m6 + +void m7; +>void m7 : undefined +>m7 : typeof m7 + +void m8; +>void m8 : undefined +>m8 : typeof m8 + +void m9; +>void m9 : undefined +>m9 : typeof m9 + +void m10; +>void m10 : undefined +>m10 : typeof m10 + +void m11; +>void m11 : undefined +>m11 : typeof m11 + +void m12; +>void m12 : undefined +>m12 : typeof m12 + +// cjs format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + === tests/cases/conformance/node/index.ts === +import * as m1 from "./index.js"; +>m1 : typeof m1 + +import * as m2 from "./index.mjs"; +>m2 : typeof m2 + +import * as m3 from "./index.cjs"; +>m3 : typeof m3 + +import * as m4 from "./subfolder/index.js"; +>m4 : typeof m4 + +import * as m5 from "./subfolder/index.mjs"; +>m5 : typeof m5 + +import * as m6 from "./subfolder/index.cjs"; +>m6 : typeof m6 + +import * as m7 from "./subfolder2/index.js"; +>m7 : typeof m7 + +import * as m8 from "./subfolder2/index.mjs"; +>m8 : typeof m8 + +import * as m9 from "./subfolder2/index.cjs"; +>m9 : typeof m9 + +import * as m10 from "./subfolder2/another/index.js"; +>m10 : typeof m10 + +import * as m11 from "./subfolder2/another/index.mjs"; +>m11 : typeof m11 + +import * as m12 from "./subfolder2/another/index.cjs"; +>m12 : typeof m12 + +void m1; +>void m1 : undefined +>m1 : typeof m1 + +void m2; +>void m2 : undefined +>m2 : typeof m2 + +void m3; +>void m3 : undefined +>m3 : typeof m3 + +void m4; +>void m4 : undefined +>m4 : typeof m4 + +void m5; +>void m5 : undefined +>m5 : typeof m5 + +void m6; +>void m6 : undefined +>m6 : typeof m6 + +void m7; +>void m7 : undefined +>m7 : typeof m7 + +void m8; +>void m8 : undefined +>m8 : typeof m8 + +void m9; +>void m9 : undefined +>m9 : typeof m9 + +void m10; +>void m10 : undefined +>m10 : typeof m10 + +void m11; +>void m11 : undefined +>m11 : typeof m11 + +void m12; +>void m12 : undefined +>m12 : typeof m12 + // esm format file const x = 1; >x : 1 diff --git a/tests/baselines/reference/nodeModules1(module=nodenext).errors.txt b/tests/baselines/reference/nodeModules1(module=nodenext).errors.txt new file mode 100644 index 0000000000000..8ee0d921d50d2 --- /dev/null +++ b/tests/baselines/reference/nodeModules1(module=nodenext).errors.txt @@ -0,0 +1,158 @@ +tests/cases/conformance/node/index.cts(2,21): error TS1435: Module './index.js' 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/index.cts(3,21): error TS1435: Module './index.mjs' 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/index.cts(6,21): error TS1435: Module './subfolder/index.mjs' 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/index.cts(9,21): error TS1435: Module './subfolder2/index.mjs' 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/index.cts(11,22): error TS1435: Module './subfolder2/another/index.js' 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/index.cts(12,22): error TS1435: Module './subfolder2/another/index.mjs' 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/subfolder/index.ts (0 errors) ==== + // cjs format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/subfolder/index.cts (0 errors) ==== + // cjs format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/subfolder/index.mts (0 errors) ==== + // esm format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/subfolder2/index.ts (0 errors) ==== + // cjs format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/subfolder2/index.cts (0 errors) ==== + // cjs format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/subfolder2/index.mts (0 errors) ==== + // esm format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/subfolder2/another/index.ts (0 errors) ==== + // esm format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/subfolder2/another/index.mts (0 errors) ==== + // esm format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/subfolder2/another/index.cts (0 errors) ==== + // cjs format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/index.mts (0 errors) ==== + import * as m1 from "./index.js"; + import * as m2 from "./index.mjs"; + import * as m3 from "./index.cjs"; + import * as m4 from "./subfolder/index.js"; + import * as m5 from "./subfolder/index.mjs"; + import * as m6 from "./subfolder/index.cjs"; + import * as m7 from "./subfolder2/index.js"; + import * as m8 from "./subfolder2/index.mjs"; + import * as m9 from "./subfolder2/index.cjs"; + import * as m10 from "./subfolder2/another/index.js"; + import * as m11 from "./subfolder2/another/index.mjs"; + import * as m12 from "./subfolder2/another/index.cjs"; + void m1; + void m2; + void m3; + void m4; + void m5; + void m6; + void m7; + void m8; + void m9; + void m10; + void m11; + void m12; + // esm format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/index.cts (6 errors) ==== + // ESM-format imports below should issue errors + import * as m1 from "./index.js"; + ~~~~~~~~~~~~ +!!! error TS1435: Module './index.js' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. + import * as m2 from "./index.mjs"; + ~~~~~~~~~~~~~ +!!! error TS1435: Module './index.mjs' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. + import * as m3 from "./index.cjs"; + import * as m4 from "./subfolder/index.js"; + import * as m5 from "./subfolder/index.mjs"; + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1435: Module './subfolder/index.mjs' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. + import * as m6 from "./subfolder/index.cjs"; + import * as m7 from "./subfolder2/index.js"; + import * as m8 from "./subfolder2/index.mjs"; + ~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1435: Module './subfolder2/index.mjs' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. + import * as m9 from "./subfolder2/index.cjs"; + import * as m10 from "./subfolder2/another/index.js"; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1435: Module './subfolder2/another/index.js' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. + import * as m11 from "./subfolder2/another/index.mjs"; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1435: Module './subfolder2/another/index.mjs' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. + import * as m12 from "./subfolder2/another/index.cjs"; + void m1; + void m2; + void m3; + void m4; + void m5; + void m6; + void m7; + void m8; + void m9; + void m10; + void m11; + void m12; + // cjs format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/index.ts (0 errors) ==== + import * as m1 from "./index.js"; + import * as m2 from "./index.mjs"; + import * as m3 from "./index.cjs"; + import * as m4 from "./subfolder/index.js"; + import * as m5 from "./subfolder/index.mjs"; + import * as m6 from "./subfolder/index.cjs"; + import * as m7 from "./subfolder2/index.js"; + import * as m8 from "./subfolder2/index.mjs"; + import * as m9 from "./subfolder2/index.cjs"; + import * as m10 from "./subfolder2/another/index.js"; + import * as m11 from "./subfolder2/another/index.mjs"; + import * as m12 from "./subfolder2/another/index.cjs"; + void m1; + void m2; + void m3; + void m4; + void m5; + void m6; + void m7; + void m8; + void m9; + void m10; + void m11; + void m12; + // esm format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module" + } +==== tests/cases/conformance/node/subfolder/package.json (0 errors) ==== + { + "type": "commonjs" + } +==== tests/cases/conformance/node/subfolder2/package.json (0 errors) ==== + { + } +==== tests/cases/conformance/node/subfolder2/another/package.json (0 errors) ==== + { + "type": "module" + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModules1(module=nodenext).js b/tests/baselines/reference/nodeModules1(module=nodenext).js index 1acae5c9aab3b..fba5f41f193e3 100644 --- a/tests/baselines/reference/nodeModules1(module=nodenext).js +++ b/tests/baselines/reference/nodeModules1(module=nodenext).js @@ -4,15 +4,120 @@ // cjs format file const x = 1; export {x}; +//// [index.cts] +// cjs format file +const x = 1; +export {x}; +//// [index.mts] +// esm format file +const x = 1; +export {x}; //// [index.ts] // cjs format file const x = 1; export {x}; +//// [index.cts] +// cjs format file +const x = 1; +export {x}; +//// [index.mts] +// esm format file +const x = 1; +export {x}; //// [index.ts] // esm format file const x = 1; export {x}; +//// [index.mts] +// esm format file +const x = 1; +export {x}; +//// [index.cts] +// cjs format file +const x = 1; +export {x}; +//// [index.mts] +import * as m1 from "./index.js"; +import * as m2 from "./index.mjs"; +import * as m3 from "./index.cjs"; +import * as m4 from "./subfolder/index.js"; +import * as m5 from "./subfolder/index.mjs"; +import * as m6 from "./subfolder/index.cjs"; +import * as m7 from "./subfolder2/index.js"; +import * as m8 from "./subfolder2/index.mjs"; +import * as m9 from "./subfolder2/index.cjs"; +import * as m10 from "./subfolder2/another/index.js"; +import * as m11 from "./subfolder2/another/index.mjs"; +import * as m12 from "./subfolder2/another/index.cjs"; +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; +// esm format file +const x = 1; +export {x}; +//// [index.cts] +// ESM-format imports below should issue errors +import * as m1 from "./index.js"; +import * as m2 from "./index.mjs"; +import * as m3 from "./index.cjs"; +import * as m4 from "./subfolder/index.js"; +import * as m5 from "./subfolder/index.mjs"; +import * as m6 from "./subfolder/index.cjs"; +import * as m7 from "./subfolder2/index.js"; +import * as m8 from "./subfolder2/index.mjs"; +import * as m9 from "./subfolder2/index.cjs"; +import * as m10 from "./subfolder2/another/index.js"; +import * as m11 from "./subfolder2/another/index.mjs"; +import * as m12 from "./subfolder2/another/index.cjs"; +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; +// cjs format file +const x = 1; +export {x}; //// [index.ts] +import * as m1 from "./index.js"; +import * as m2 from "./index.mjs"; +import * as m3 from "./index.cjs"; +import * as m4 from "./subfolder/index.js"; +import * as m5 from "./subfolder/index.mjs"; +import * as m6 from "./subfolder/index.cjs"; +import * as m7 from "./subfolder2/index.js"; +import * as m8 from "./subfolder2/index.mjs"; +import * as m9 from "./subfolder2/index.cjs"; +import * as m10 from "./subfolder2/another/index.js"; +import * as m11 from "./subfolder2/another/index.mjs"; +import * as m12 from "./subfolder2/another/index.cjs"; +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; // esm format file const x = 1; export {x}; @@ -41,6 +146,17 @@ exports.x = void 0; // cjs format file const x = 1; exports.x = x; +//// [index.cjs] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +// cjs format file +const x = 1; +exports.x = x; +//// [index.mjs] +// esm format file +const x = 1; +export { x }; //// [index.js] "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); @@ -48,25 +164,174 @@ exports.x = void 0; // cjs format file const x = 1; exports.x = x; +//// [index.cjs] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +// cjs format file +const x = 1; +exports.x = x; +//// [index.mjs] +// esm format file +const x = 1; +export { x }; //// [index.js] // esm format file const x = 1; export { x }; +//// [index.mjs] +// esm format file +const x = 1; +export { x }; +//// [index.cjs] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +// cjs format file +const x = 1; +exports.x = x; //// [index.js] +import * as m1 from "./index.js"; +import * as m2 from "./index.mjs"; +import * as m3 from "./index.cjs"; +import * as m4 from "./subfolder/index.js"; +import * as m5 from "./subfolder/index.mjs"; +import * as m6 from "./subfolder/index.cjs"; +import * as m7 from "./subfolder2/index.js"; +import * as m8 from "./subfolder2/index.mjs"; +import * as m9 from "./subfolder2/index.cjs"; +import * as m10 from "./subfolder2/another/index.js"; +import * as m11 from "./subfolder2/another/index.mjs"; +import * as m12 from "./subfolder2/another/index.cjs"; +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; // esm format file const x = 1; export { x }; +//// [index.mjs] +import * as m1 from "./index.js"; +import * as m2 from "./index.mjs"; +import * as m3 from "./index.cjs"; +import * as m4 from "./subfolder/index.js"; +import * as m5 from "./subfolder/index.mjs"; +import * as m6 from "./subfolder/index.cjs"; +import * as m7 from "./subfolder2/index.js"; +import * as m8 from "./subfolder2/index.mjs"; +import * as m9 from "./subfolder2/index.cjs"; +import * as m10 from "./subfolder2/another/index.js"; +import * as m11 from "./subfolder2/another/index.mjs"; +import * as m12 from "./subfolder2/another/index.cjs"; +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; +// esm format file +const x = 1; +export { x }; +//// [index.cjs] +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +// ESM-format imports below should issue errors +const m1 = __importStar(require("./index.js")); +const m2 = __importStar(require("./index.mjs")); +const m3 = __importStar(require("./index.cjs")); +const m4 = __importStar(require("./subfolder/index.js")); +const m5 = __importStar(require("./subfolder/index.mjs")); +const m6 = __importStar(require("./subfolder/index.cjs")); +const m7 = __importStar(require("./subfolder2/index.js")); +const m8 = __importStar(require("./subfolder2/index.mjs")); +const m9 = __importStar(require("./subfolder2/index.cjs")); +const m10 = __importStar(require("./subfolder2/another/index.js")); +const m11 = __importStar(require("./subfolder2/another/index.mjs")); +const m12 = __importStar(require("./subfolder2/another/index.cjs")); +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; +// cjs format file +const x = 1; +exports.x = x; //// [index.d.ts] declare const x = 1; export { x }; +//// [index.d.cts] +declare const x = 1; +export { x }; +//// [index.d.mts] +declare const x = 1; +export { x }; //// [index.d.ts] declare const x = 1; export { x }; +//// [index.d.cts] +declare const x = 1; +export { x }; +//// [index.d.mts] +declare const x = 1; +export { x }; //// [index.d.ts] declare const x = 1; export { x }; +//// [index.d.mts] +declare const x = 1; +export { x }; +//// [index.d.cts] +declare const x = 1; +export { x }; //// [index.d.ts] declare const x = 1; export { x }; +//// [index.d.mts] +declare const x = 1; +export { x }; +//// [index.d.cts] +declare const x = 1; +export { x }; diff --git a/tests/baselines/reference/nodeModules1(module=nodenext).symbols b/tests/baselines/reference/nodeModules1(module=nodenext).symbols index e1653429c87db..b8caa52c8cfa0 100644 --- a/tests/baselines/reference/nodeModules1(module=nodenext).symbols +++ b/tests/baselines/reference/nodeModules1(module=nodenext).symbols @@ -6,6 +6,22 @@ const x = 1; export {x}; >x : Symbol(x, Decl(index.ts, 2, 8)) +=== tests/cases/conformance/node/subfolder/index.cts === +// cjs format file +const x = 1; +>x : Symbol(x, Decl(index.cts, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.cts, 2, 8)) + +=== tests/cases/conformance/node/subfolder/index.mts === +// esm format file +const x = 1; +>x : Symbol(x, Decl(index.mts, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.mts, 2, 8)) + === tests/cases/conformance/node/subfolder2/index.ts === // cjs format file const x = 1; @@ -14,6 +30,22 @@ const x = 1; export {x}; >x : Symbol(x, Decl(index.ts, 2, 8)) +=== tests/cases/conformance/node/subfolder2/index.cts === +// cjs format file +const x = 1; +>x : Symbol(x, Decl(index.cts, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.cts, 2, 8)) + +=== tests/cases/conformance/node/subfolder2/index.mts === +// esm format file +const x = 1; +>x : Symbol(x, Decl(index.mts, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.mts, 2, 8)) + === tests/cases/conformance/node/subfolder2/another/index.ts === // esm format file const x = 1; @@ -22,11 +54,260 @@ const x = 1; export {x}; >x : Symbol(x, Decl(index.ts, 2, 8)) +=== tests/cases/conformance/node/subfolder2/another/index.mts === +// esm format file +const x = 1; +>x : Symbol(x, Decl(index.mts, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.mts, 2, 8)) + +=== tests/cases/conformance/node/subfolder2/another/index.cts === +// cjs format file +const x = 1; +>x : Symbol(x, Decl(index.cts, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.cts, 2, 8)) + +=== tests/cases/conformance/node/index.mts === +import * as m1 from "./index.js"; +>m1 : Symbol(m1, Decl(index.mts, 0, 6)) + +import * as m2 from "./index.mjs"; +>m2 : Symbol(m2, Decl(index.mts, 1, 6)) + +import * as m3 from "./index.cjs"; +>m3 : Symbol(m3, Decl(index.mts, 2, 6)) + +import * as m4 from "./subfolder/index.js"; +>m4 : Symbol(m4, Decl(index.mts, 3, 6)) + +import * as m5 from "./subfolder/index.mjs"; +>m5 : Symbol(m5, Decl(index.mts, 4, 6)) + +import * as m6 from "./subfolder/index.cjs"; +>m6 : Symbol(m6, Decl(index.mts, 5, 6)) + +import * as m7 from "./subfolder2/index.js"; +>m7 : Symbol(m7, Decl(index.mts, 6, 6)) + +import * as m8 from "./subfolder2/index.mjs"; +>m8 : Symbol(m8, Decl(index.mts, 7, 6)) + +import * as m9 from "./subfolder2/index.cjs"; +>m9 : Symbol(m9, Decl(index.mts, 8, 6)) + +import * as m10 from "./subfolder2/another/index.js"; +>m10 : Symbol(m10, Decl(index.mts, 9, 6)) + +import * as m11 from "./subfolder2/another/index.mjs"; +>m11 : Symbol(m11, Decl(index.mts, 10, 6)) + +import * as m12 from "./subfolder2/another/index.cjs"; +>m12 : Symbol(m12, Decl(index.mts, 11, 6)) + +void m1; +>m1 : Symbol(m1, Decl(index.mts, 0, 6)) + +void m2; +>m2 : Symbol(m2, Decl(index.mts, 1, 6)) + +void m3; +>m3 : Symbol(m3, Decl(index.mts, 2, 6)) + +void m4; +>m4 : Symbol(m4, Decl(index.mts, 3, 6)) + +void m5; +>m5 : Symbol(m5, Decl(index.mts, 4, 6)) + +void m6; +>m6 : Symbol(m6, Decl(index.mts, 5, 6)) + +void m7; +>m7 : Symbol(m7, Decl(index.mts, 6, 6)) + +void m8; +>m8 : Symbol(m8, Decl(index.mts, 7, 6)) + +void m9; +>m9 : Symbol(m9, Decl(index.mts, 8, 6)) + +void m10; +>m10 : Symbol(m10, Decl(index.mts, 9, 6)) + +void m11; +>m11 : Symbol(m11, Decl(index.mts, 10, 6)) + +void m12; +>m12 : Symbol(m12, Decl(index.mts, 11, 6)) + +// esm format file +const x = 1; +>x : Symbol(x, Decl(index.mts, 25, 5)) + +export {x}; +>x : Symbol(m2.x, Decl(index.mts, 26, 8)) + +=== tests/cases/conformance/node/index.cts === +// ESM-format imports below should issue errors +import * as m1 from "./index.js"; +>m1 : Symbol(m1, Decl(index.cts, 1, 6)) + +import * as m2 from "./index.mjs"; +>m2 : Symbol(m2, Decl(index.cts, 2, 6)) + +import * as m3 from "./index.cjs"; +>m3 : Symbol(m3, Decl(index.cts, 3, 6)) + +import * as m4 from "./subfolder/index.js"; +>m4 : Symbol(m4, Decl(index.cts, 4, 6)) + +import * as m5 from "./subfolder/index.mjs"; +>m5 : Symbol(m5, Decl(index.cts, 5, 6)) + +import * as m6 from "./subfolder/index.cjs"; +>m6 : Symbol(m6, Decl(index.cts, 6, 6)) + +import * as m7 from "./subfolder2/index.js"; +>m7 : Symbol(m7, Decl(index.cts, 7, 6)) + +import * as m8 from "./subfolder2/index.mjs"; +>m8 : Symbol(m8, Decl(index.cts, 8, 6)) + +import * as m9 from "./subfolder2/index.cjs"; +>m9 : Symbol(m9, Decl(index.cts, 9, 6)) + +import * as m10 from "./subfolder2/another/index.js"; +>m10 : Symbol(m10, Decl(index.cts, 10, 6)) + +import * as m11 from "./subfolder2/another/index.mjs"; +>m11 : Symbol(m11, Decl(index.cts, 11, 6)) + +import * as m12 from "./subfolder2/another/index.cjs"; +>m12 : Symbol(m12, Decl(index.cts, 12, 6)) + +void m1; +>m1 : Symbol(m1, Decl(index.cts, 1, 6)) + +void m2; +>m2 : Symbol(m2, Decl(index.cts, 2, 6)) + +void m3; +>m3 : Symbol(m3, Decl(index.cts, 3, 6)) + +void m4; +>m4 : Symbol(m4, Decl(index.cts, 4, 6)) + +void m5; +>m5 : Symbol(m5, Decl(index.cts, 5, 6)) + +void m6; +>m6 : Symbol(m6, Decl(index.cts, 6, 6)) + +void m7; +>m7 : Symbol(m7, Decl(index.cts, 7, 6)) + +void m8; +>m8 : Symbol(m8, Decl(index.cts, 8, 6)) + +void m9; +>m9 : Symbol(m9, Decl(index.cts, 9, 6)) + +void m10; +>m10 : Symbol(m10, Decl(index.cts, 10, 6)) + +void m11; +>m11 : Symbol(m11, Decl(index.cts, 11, 6)) + +void m12; +>m12 : Symbol(m12, Decl(index.cts, 12, 6)) + +// cjs format file +const x = 1; +>x : Symbol(x, Decl(index.cts, 26, 5)) + +export {x}; +>x : Symbol(m3.x, Decl(index.cts, 27, 8)) + === tests/cases/conformance/node/index.ts === +import * as m1 from "./index.js"; +>m1 : Symbol(m1, Decl(index.ts, 0, 6)) + +import * as m2 from "./index.mjs"; +>m2 : Symbol(m2, Decl(index.ts, 1, 6)) + +import * as m3 from "./index.cjs"; +>m3 : Symbol(m3, Decl(index.ts, 2, 6)) + +import * as m4 from "./subfolder/index.js"; +>m4 : Symbol(m4, Decl(index.ts, 3, 6)) + +import * as m5 from "./subfolder/index.mjs"; +>m5 : Symbol(m5, Decl(index.ts, 4, 6)) + +import * as m6 from "./subfolder/index.cjs"; +>m6 : Symbol(m6, Decl(index.ts, 5, 6)) + +import * as m7 from "./subfolder2/index.js"; +>m7 : Symbol(m7, Decl(index.ts, 6, 6)) + +import * as m8 from "./subfolder2/index.mjs"; +>m8 : Symbol(m8, Decl(index.ts, 7, 6)) + +import * as m9 from "./subfolder2/index.cjs"; +>m9 : Symbol(m9, Decl(index.ts, 8, 6)) + +import * as m10 from "./subfolder2/another/index.js"; +>m10 : Symbol(m10, Decl(index.ts, 9, 6)) + +import * as m11 from "./subfolder2/another/index.mjs"; +>m11 : Symbol(m11, Decl(index.ts, 10, 6)) + +import * as m12 from "./subfolder2/another/index.cjs"; +>m12 : Symbol(m12, Decl(index.ts, 11, 6)) + +void m1; +>m1 : Symbol(m1, Decl(index.ts, 0, 6)) + +void m2; +>m2 : Symbol(m2, Decl(index.ts, 1, 6)) + +void m3; +>m3 : Symbol(m3, Decl(index.ts, 2, 6)) + +void m4; +>m4 : Symbol(m4, Decl(index.ts, 3, 6)) + +void m5; +>m5 : Symbol(m5, Decl(index.ts, 4, 6)) + +void m6; +>m6 : Symbol(m6, Decl(index.ts, 5, 6)) + +void m7; +>m7 : Symbol(m7, Decl(index.ts, 6, 6)) + +void m8; +>m8 : Symbol(m8, Decl(index.ts, 7, 6)) + +void m9; +>m9 : Symbol(m9, Decl(index.ts, 8, 6)) + +void m10; +>m10 : Symbol(m10, Decl(index.ts, 9, 6)) + +void m11; +>m11 : Symbol(m11, Decl(index.ts, 10, 6)) + +void m12; +>m12 : Symbol(m12, Decl(index.ts, 11, 6)) + // esm format file const x = 1; ->x : Symbol(x, Decl(index.ts, 1, 5)) +>x : Symbol(x, Decl(index.ts, 25, 5)) export {x}; ->x : Symbol(x, Decl(index.ts, 2, 8)) +>x : Symbol(m1.x, Decl(index.ts, 26, 8)) diff --git a/tests/baselines/reference/nodeModules1(module=nodenext).types b/tests/baselines/reference/nodeModules1(module=nodenext).types index 1c479a5e7bd48..cf878a592d2e9 100644 --- a/tests/baselines/reference/nodeModules1(module=nodenext).types +++ b/tests/baselines/reference/nodeModules1(module=nodenext).types @@ -7,6 +7,24 @@ const x = 1; export {x}; >x : 1 +=== tests/cases/conformance/node/subfolder/index.cts === +// cjs format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + +=== tests/cases/conformance/node/subfolder/index.mts === +// esm format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + === tests/cases/conformance/node/subfolder2/index.ts === // cjs format file const x = 1; @@ -16,6 +34,24 @@ const x = 1; export {x}; >x : 1 +=== tests/cases/conformance/node/subfolder2/index.cts === +// cjs format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + +=== tests/cases/conformance/node/subfolder2/index.mts === +// esm format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + === tests/cases/conformance/node/subfolder2/another/index.ts === // esm format file const x = 1; @@ -25,7 +61,296 @@ const x = 1; export {x}; >x : 1 +=== tests/cases/conformance/node/subfolder2/another/index.mts === +// esm format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + +=== tests/cases/conformance/node/subfolder2/another/index.cts === +// cjs format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + +=== tests/cases/conformance/node/index.mts === +import * as m1 from "./index.js"; +>m1 : typeof m1 + +import * as m2 from "./index.mjs"; +>m2 : typeof m2 + +import * as m3 from "./index.cjs"; +>m3 : typeof m3 + +import * as m4 from "./subfolder/index.js"; +>m4 : typeof m4 + +import * as m5 from "./subfolder/index.mjs"; +>m5 : typeof m5 + +import * as m6 from "./subfolder/index.cjs"; +>m6 : typeof m6 + +import * as m7 from "./subfolder2/index.js"; +>m7 : typeof m7 + +import * as m8 from "./subfolder2/index.mjs"; +>m8 : typeof m8 + +import * as m9 from "./subfolder2/index.cjs"; +>m9 : typeof m9 + +import * as m10 from "./subfolder2/another/index.js"; +>m10 : typeof m10 + +import * as m11 from "./subfolder2/another/index.mjs"; +>m11 : typeof m11 + +import * as m12 from "./subfolder2/another/index.cjs"; +>m12 : typeof m12 + +void m1; +>void m1 : undefined +>m1 : typeof m1 + +void m2; +>void m2 : undefined +>m2 : typeof m2 + +void m3; +>void m3 : undefined +>m3 : typeof m3 + +void m4; +>void m4 : undefined +>m4 : typeof m4 + +void m5; +>void m5 : undefined +>m5 : typeof m5 + +void m6; +>void m6 : undefined +>m6 : typeof m6 + +void m7; +>void m7 : undefined +>m7 : typeof m7 + +void m8; +>void m8 : undefined +>m8 : typeof m8 + +void m9; +>void m9 : undefined +>m9 : typeof m9 + +void m10; +>void m10 : undefined +>m10 : typeof m10 + +void m11; +>void m11 : undefined +>m11 : typeof m11 + +void m12; +>void m12 : undefined +>m12 : typeof m12 + +// esm format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + +=== tests/cases/conformance/node/index.cts === +// ESM-format imports below should issue errors +import * as m1 from "./index.js"; +>m1 : typeof m1 + +import * as m2 from "./index.mjs"; +>m2 : typeof m2 + +import * as m3 from "./index.cjs"; +>m3 : typeof m3 + +import * as m4 from "./subfolder/index.js"; +>m4 : typeof m4 + +import * as m5 from "./subfolder/index.mjs"; +>m5 : typeof m5 + +import * as m6 from "./subfolder/index.cjs"; +>m6 : typeof m6 + +import * as m7 from "./subfolder2/index.js"; +>m7 : typeof m7 + +import * as m8 from "./subfolder2/index.mjs"; +>m8 : typeof m8 + +import * as m9 from "./subfolder2/index.cjs"; +>m9 : typeof m9 + +import * as m10 from "./subfolder2/another/index.js"; +>m10 : typeof m10 + +import * as m11 from "./subfolder2/another/index.mjs"; +>m11 : typeof m11 + +import * as m12 from "./subfolder2/another/index.cjs"; +>m12 : typeof m12 + +void m1; +>void m1 : undefined +>m1 : typeof m1 + +void m2; +>void m2 : undefined +>m2 : typeof m2 + +void m3; +>void m3 : undefined +>m3 : typeof m3 + +void m4; +>void m4 : undefined +>m4 : typeof m4 + +void m5; +>void m5 : undefined +>m5 : typeof m5 + +void m6; +>void m6 : undefined +>m6 : typeof m6 + +void m7; +>void m7 : undefined +>m7 : typeof m7 + +void m8; +>void m8 : undefined +>m8 : typeof m8 + +void m9; +>void m9 : undefined +>m9 : typeof m9 + +void m10; +>void m10 : undefined +>m10 : typeof m10 + +void m11; +>void m11 : undefined +>m11 : typeof m11 + +void m12; +>void m12 : undefined +>m12 : typeof m12 + +// cjs format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + === tests/cases/conformance/node/index.ts === +import * as m1 from "./index.js"; +>m1 : typeof m1 + +import * as m2 from "./index.mjs"; +>m2 : typeof m2 + +import * as m3 from "./index.cjs"; +>m3 : typeof m3 + +import * as m4 from "./subfolder/index.js"; +>m4 : typeof m4 + +import * as m5 from "./subfolder/index.mjs"; +>m5 : typeof m5 + +import * as m6 from "./subfolder/index.cjs"; +>m6 : typeof m6 + +import * as m7 from "./subfolder2/index.js"; +>m7 : typeof m7 + +import * as m8 from "./subfolder2/index.mjs"; +>m8 : typeof m8 + +import * as m9 from "./subfolder2/index.cjs"; +>m9 : typeof m9 + +import * as m10 from "./subfolder2/another/index.js"; +>m10 : typeof m10 + +import * as m11 from "./subfolder2/another/index.mjs"; +>m11 : typeof m11 + +import * as m12 from "./subfolder2/another/index.cjs"; +>m12 : typeof m12 + +void m1; +>void m1 : undefined +>m1 : typeof m1 + +void m2; +>void m2 : undefined +>m2 : typeof m2 + +void m3; +>void m3 : undefined +>m3 : typeof m3 + +void m4; +>void m4 : undefined +>m4 : typeof m4 + +void m5; +>void m5 : undefined +>m5 : typeof m5 + +void m6; +>void m6 : undefined +>m6 : typeof m6 + +void m7; +>void m7 : undefined +>m7 : typeof m7 + +void m8; +>void m8 : undefined +>m8 : typeof m8 + +void m9; +>void m9 : undefined +>m9 : typeof m9 + +void m10; +>void m10 : undefined +>m10 : typeof m10 + +void m11; +>void m11 : undefined +>m11 : typeof m11 + +void m12; +>void m12 : undefined +>m12 : typeof m12 + // esm format file const x = 1; >x : 1 diff --git a/tests/baselines/reference/nodeModulesAllowJs1(module=node12).errors.txt b/tests/baselines/reference/nodeModulesAllowJs1(module=node12).errors.txt new file mode 100644 index 0000000000000..d2d1c33f60189 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJs1(module=node12).errors.txt @@ -0,0 +1,158 @@ +tests/cases/conformance/node/allowJs/index.cjs(2,21): error TS1435: Module './index.js' 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(3,21): error TS1435: Module './index.mjs' 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(6,21): error TS1435: Module './subfolder/index.mjs' 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(9,21): error TS1435: Module './subfolder2/index.mjs' 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(11,22): error TS1435: Module './subfolder2/another/index.js' 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(12,22): error TS1435: Module './subfolder2/another/index.mjs' 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/subfolder/index.js (0 errors) ==== + // cjs format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/allowJs/subfolder/index.cjs (0 errors) ==== + // cjs format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/allowJs/subfolder/index.mjs (0 errors) ==== + // esm format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/allowJs/subfolder2/index.js (0 errors) ==== + // cjs format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/allowJs/subfolder2/index.cjs (0 errors) ==== + // cjs format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/allowJs/subfolder2/index.mjs (0 errors) ==== + // esm format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/allowJs/subfolder2/another/index.js (0 errors) ==== + // esm format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/allowJs/subfolder2/another/index.cjs (0 errors) ==== + // cjs format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/allowJs/subfolder2/another/index.mjs (0 errors) ==== + // esm format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/allowJs/index.js (0 errors) ==== + import * as m1 from "./index.js"; + import * as m2 from "./index.mjs"; + import * as m3 from "./index.cjs"; + import * as m4 from "./subfolder/index.js"; + import * as m5 from "./subfolder/index.mjs"; + import * as m6 from "./subfolder/index.cjs"; + import * as m7 from "./subfolder2/index.js"; + import * as m8 from "./subfolder2/index.mjs"; + import * as m9 from "./subfolder2/index.cjs"; + import * as m10 from "./subfolder2/another/index.js"; + import * as m11 from "./subfolder2/another/index.mjs"; + import * as m12 from "./subfolder2/another/index.cjs"; + void m1; + void m2; + void m3; + void m4; + void m5; + void m6; + void m7; + void m8; + void m9; + void m10; + void m11; + void m12; + // esm format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/allowJs/index.cjs (6 errors) ==== + // ESM format imports below should error + import * as m1 from "./index.js"; + ~~~~~~~~~~~~ +!!! error TS1435: Module './index.js' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. + import * as m2 from "./index.mjs"; + ~~~~~~~~~~~~~ +!!! error TS1435: Module './index.mjs' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. + import * as m3 from "./index.cjs"; + import * as m4 from "./subfolder/index.js"; + import * as m5 from "./subfolder/index.mjs"; + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1435: Module './subfolder/index.mjs' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. + import * as m6 from "./subfolder/index.cjs"; + import * as m7 from "./subfolder2/index.js"; + import * as m8 from "./subfolder2/index.mjs"; + ~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1435: Module './subfolder2/index.mjs' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. + import * as m9 from "./subfolder2/index.cjs"; + import * as m10 from "./subfolder2/another/index.js"; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1435: Module './subfolder2/another/index.js' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. + import * as m11 from "./subfolder2/another/index.mjs"; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1435: Module './subfolder2/another/index.mjs' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. + import * as m12 from "./subfolder2/another/index.cjs"; + void m1; + void m2; + void m3; + void m4; + void m5; + void m6; + void m7; + void m8; + void m9; + void m10; + void m11; + void m12; + // cjs format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/allowJs/index.mjs (0 errors) ==== + import * as m1 from "./index.js"; + import * as m2 from "./index.mjs"; + import * as m3 from "./index.cjs"; + import * as m4 from "./subfolder/index.js"; + import * as m5 from "./subfolder/index.mjs"; + import * as m6 from "./subfolder/index.cjs"; + import * as m7 from "./subfolder2/index.js"; + import * as m8 from "./subfolder2/index.mjs"; + import * as m9 from "./subfolder2/index.cjs"; + import * as m10 from "./subfolder2/another/index.js"; + import * as m11 from "./subfolder2/another/index.mjs"; + import * as m12 from "./subfolder2/another/index.cjs"; + void m1; + void m2; + void m3; + void m4; + void m5; + void m6; + void m7; + void m8; + void m9; + void m10; + void m11; + void m12; + // esm format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/allowJs/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module" + } +==== tests/cases/conformance/node/allowJs/subfolder/package.json (0 errors) ==== + { + "type": "commonjs" + } +==== tests/cases/conformance/node/allowJs/subfolder2/package.json (0 errors) ==== + { + } +==== tests/cases/conformance/node/allowJs/subfolder2/another/package.json (0 errors) ==== + { + "type": "module" + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesAllowJs1(module=node12).js b/tests/baselines/reference/nodeModulesAllowJs1(module=node12).js index 358104e5f6a62..0ec674cdd18b3 100644 --- a/tests/baselines/reference/nodeModulesAllowJs1(module=node12).js +++ b/tests/baselines/reference/nodeModulesAllowJs1(module=node12).js @@ -4,15 +4,120 @@ // cjs format file const x = 1; export {x}; +//// [index.cjs] +// cjs format file +const x = 1; +export {x}; +//// [index.mjs] +// esm format file +const x = 1; +export {x}; //// [index.js] // cjs format file const x = 1; export {x}; +//// [index.cjs] +// cjs format file +const x = 1; +export {x}; +//// [index.mjs] +// esm format file +const x = 1; +export {x}; //// [index.js] // esm format file const x = 1; export {x}; +//// [index.cjs] +// cjs format file +const x = 1; +export {x}; +//// [index.mjs] +// esm format file +const x = 1; +export {x}; //// [index.js] +import * as m1 from "./index.js"; +import * as m2 from "./index.mjs"; +import * as m3 from "./index.cjs"; +import * as m4 from "./subfolder/index.js"; +import * as m5 from "./subfolder/index.mjs"; +import * as m6 from "./subfolder/index.cjs"; +import * as m7 from "./subfolder2/index.js"; +import * as m8 from "./subfolder2/index.mjs"; +import * as m9 from "./subfolder2/index.cjs"; +import * as m10 from "./subfolder2/another/index.js"; +import * as m11 from "./subfolder2/another/index.mjs"; +import * as m12 from "./subfolder2/another/index.cjs"; +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; +// esm format file +const x = 1; +export {x}; +//// [index.cjs] +// ESM format imports below should error +import * as m1 from "./index.js"; +import * as m2 from "./index.mjs"; +import * as m3 from "./index.cjs"; +import * as m4 from "./subfolder/index.js"; +import * as m5 from "./subfolder/index.mjs"; +import * as m6 from "./subfolder/index.cjs"; +import * as m7 from "./subfolder2/index.js"; +import * as m8 from "./subfolder2/index.mjs"; +import * as m9 from "./subfolder2/index.cjs"; +import * as m10 from "./subfolder2/another/index.js"; +import * as m11 from "./subfolder2/another/index.mjs"; +import * as m12 from "./subfolder2/another/index.cjs"; +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; +// cjs format file +const x = 1; +export {x}; +//// [index.mjs] +import * as m1 from "./index.js"; +import * as m2 from "./index.mjs"; +import * as m3 from "./index.cjs"; +import * as m4 from "./subfolder/index.js"; +import * as m5 from "./subfolder/index.mjs"; +import * as m6 from "./subfolder/index.cjs"; +import * as m7 from "./subfolder2/index.js"; +import * as m8 from "./subfolder2/index.mjs"; +import * as m9 from "./subfolder2/index.cjs"; +import * as m10 from "./subfolder2/another/index.js"; +import * as m11 from "./subfolder2/another/index.mjs"; +import * as m12 from "./subfolder2/another/index.cjs"; +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; // esm format file const x = 1; export {x}; @@ -41,6 +146,17 @@ exports.x = void 0; // cjs format file const x = 1; exports.x = x; +//// [index.cjs] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +// cjs format file +const x = 1; +exports.x = x; +//// [index.mjs] +// esm format file +const x = 1; +export { x }; //// [index.js] "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); @@ -48,11 +164,136 @@ exports.x = void 0; // cjs format file const x = 1; exports.x = x; +//// [index.cjs] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +// cjs format file +const x = 1; +exports.x = x; +//// [index.mjs] +// esm format file +const x = 1; +export { x }; //// [index.js] // esm format file const x = 1; export { x }; +//// [index.cjs] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +// cjs format file +const x = 1; +exports.x = x; +//// [index.mjs] +// esm format file +const x = 1; +export { x }; +//// [index.cjs] +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +// ESM format imports below should error +const m1 = __importStar(require("./index.js")); +const m2 = __importStar(require("./index.mjs")); +const m3 = __importStar(require("./index.cjs")); +const m4 = __importStar(require("./subfolder/index.js")); +const m5 = __importStar(require("./subfolder/index.mjs")); +const m6 = __importStar(require("./subfolder/index.cjs")); +const m7 = __importStar(require("./subfolder2/index.js")); +const m8 = __importStar(require("./subfolder2/index.mjs")); +const m9 = __importStar(require("./subfolder2/index.cjs")); +const m10 = __importStar(require("./subfolder2/another/index.js")); +const m11 = __importStar(require("./subfolder2/another/index.mjs")); +const m12 = __importStar(require("./subfolder2/another/index.cjs")); +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; +// cjs format file +const x = 1; +exports.x = x; +//// [index.mjs] +import * as m1 from "./index.js"; +import * as m2 from "./index.mjs"; +import * as m3 from "./index.cjs"; +import * as m4 from "./subfolder/index.js"; +import * as m5 from "./subfolder/index.mjs"; +import * as m6 from "./subfolder/index.cjs"; +import * as m7 from "./subfolder2/index.js"; +import * as m8 from "./subfolder2/index.mjs"; +import * as m9 from "./subfolder2/index.cjs"; +import * as m10 from "./subfolder2/another/index.js"; +import * as m11 from "./subfolder2/another/index.mjs"; +import * as m12 from "./subfolder2/another/index.cjs"; +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; +// esm format file +const x = 1; +export { x }; //// [index.js] +import * as m1 from "./index.js"; +import * as m2 from "./index.mjs"; +import * as m3 from "./index.cjs"; +import * as m4 from "./subfolder/index.js"; +import * as m5 from "./subfolder/index.mjs"; +import * as m6 from "./subfolder/index.cjs"; +import * as m7 from "./subfolder2/index.js"; +import * as m8 from "./subfolder2/index.mjs"; +import * as m9 from "./subfolder2/index.cjs"; +import * as m10 from "./subfolder2/another/index.js"; +import * as m11 from "./subfolder2/another/index.mjs"; +import * as m12 from "./subfolder2/another/index.cjs"; +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; // esm format file const x = 1; export { x }; @@ -60,9 +301,33 @@ export { x }; //// [index.d.ts] export const x: 1; +//// [index.d.cts] +declare const x = 1; +export { x }; +//// [index.d.mts] +declare const x = 1; +export { x }; //// [index.d.ts] export const x: 1; +//// [index.d.cts] +declare const x = 1; +export { x }; +//// [index.d.mts] +declare const x = 1; +export { x }; //// [index.d.ts] export const x: 1; +//// [index.d.cts] +declare const x = 1; +export { x }; +//// [index.d.mts] +declare const x = 1; +export { x }; +//// [index.d.cts] +declare const x = 1; +export { x }; +//// [index.d.mts] +declare const x = 1; +export { x }; //// [index.d.ts] export const x: 1; diff --git a/tests/baselines/reference/nodeModulesAllowJs1(module=node12).symbols b/tests/baselines/reference/nodeModulesAllowJs1(module=node12).symbols index 99bfb2a40ff73..90c86e3a1be64 100644 --- a/tests/baselines/reference/nodeModulesAllowJs1(module=node12).symbols +++ b/tests/baselines/reference/nodeModulesAllowJs1(module=node12).symbols @@ -6,6 +6,22 @@ const x = 1; export {x}; >x : Symbol(x, Decl(index.js, 2, 8)) +=== tests/cases/conformance/node/allowJs/subfolder/index.cjs === +// cjs format file +const x = 1; +>x : Symbol(x, Decl(index.cjs, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.cjs, 2, 8)) + +=== tests/cases/conformance/node/allowJs/subfolder/index.mjs === +// esm format file +const x = 1; +>x : Symbol(x, Decl(index.mjs, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.mjs, 2, 8)) + === tests/cases/conformance/node/allowJs/subfolder2/index.js === // cjs format file const x = 1; @@ -14,6 +30,22 @@ const x = 1; export {x}; >x : Symbol(x, Decl(index.js, 2, 8)) +=== tests/cases/conformance/node/allowJs/subfolder2/index.cjs === +// cjs format file +const x = 1; +>x : Symbol(x, Decl(index.cjs, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.cjs, 2, 8)) + +=== tests/cases/conformance/node/allowJs/subfolder2/index.mjs === +// esm format file +const x = 1; +>x : Symbol(x, Decl(index.mjs, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.mjs, 2, 8)) + === tests/cases/conformance/node/allowJs/subfolder2/another/index.js === // esm format file const x = 1; @@ -22,11 +54,260 @@ const x = 1; export {x}; >x : Symbol(x, Decl(index.js, 2, 8)) +=== tests/cases/conformance/node/allowJs/subfolder2/another/index.cjs === +// cjs format file +const x = 1; +>x : Symbol(x, Decl(index.cjs, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.cjs, 2, 8)) + +=== tests/cases/conformance/node/allowJs/subfolder2/another/index.mjs === +// esm format file +const x = 1; +>x : Symbol(x, Decl(index.mjs, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.mjs, 2, 8)) + === tests/cases/conformance/node/allowJs/index.js === +import * as m1 from "./index.js"; +>m1 : Symbol(m1, Decl(index.js, 0, 6)) + +import * as m2 from "./index.mjs"; +>m2 : Symbol(m2, Decl(index.js, 1, 6)) + +import * as m3 from "./index.cjs"; +>m3 : Symbol(m3, Decl(index.js, 2, 6)) + +import * as m4 from "./subfolder/index.js"; +>m4 : Symbol(m4, Decl(index.js, 3, 6)) + +import * as m5 from "./subfolder/index.mjs"; +>m5 : Symbol(m5, Decl(index.js, 4, 6)) + +import * as m6 from "./subfolder/index.cjs"; +>m6 : Symbol(m6, Decl(index.js, 5, 6)) + +import * as m7 from "./subfolder2/index.js"; +>m7 : Symbol(m7, Decl(index.js, 6, 6)) + +import * as m8 from "./subfolder2/index.mjs"; +>m8 : Symbol(m8, Decl(index.js, 7, 6)) + +import * as m9 from "./subfolder2/index.cjs"; +>m9 : Symbol(m9, Decl(index.js, 8, 6)) + +import * as m10 from "./subfolder2/another/index.js"; +>m10 : Symbol(m10, Decl(index.js, 9, 6)) + +import * as m11 from "./subfolder2/another/index.mjs"; +>m11 : Symbol(m11, Decl(index.js, 10, 6)) + +import * as m12 from "./subfolder2/another/index.cjs"; +>m12 : Symbol(m12, Decl(index.js, 11, 6)) + +void m1; +>m1 : Symbol(m1, Decl(index.js, 0, 6)) + +void m2; +>m2 : Symbol(m2, Decl(index.js, 1, 6)) + +void m3; +>m3 : Symbol(m3, Decl(index.js, 2, 6)) + +void m4; +>m4 : Symbol(m4, Decl(index.js, 3, 6)) + +void m5; +>m5 : Symbol(m5, Decl(index.js, 4, 6)) + +void m6; +>m6 : Symbol(m6, Decl(index.js, 5, 6)) + +void m7; +>m7 : Symbol(m7, Decl(index.js, 6, 6)) + +void m8; +>m8 : Symbol(m8, Decl(index.js, 7, 6)) + +void m9; +>m9 : Symbol(m9, Decl(index.js, 8, 6)) + +void m10; +>m10 : Symbol(m10, Decl(index.js, 9, 6)) + +void m11; +>m11 : Symbol(m11, Decl(index.js, 10, 6)) + +void m12; +>m12 : Symbol(m12, Decl(index.js, 11, 6)) + // esm format file const x = 1; ->x : Symbol(x, Decl(index.js, 1, 5)) +>x : Symbol(x, Decl(index.js, 25, 5)) export {x}; ->x : Symbol(x, Decl(index.js, 2, 8)) +>x : Symbol(m1.x, Decl(index.js, 26, 8)) + +=== tests/cases/conformance/node/allowJs/index.cjs === +// ESM format imports below should error +import * as m1 from "./index.js"; +>m1 : Symbol(m1, Decl(index.cjs, 1, 6)) + +import * as m2 from "./index.mjs"; +>m2 : Symbol(m2, Decl(index.cjs, 2, 6)) + +import * as m3 from "./index.cjs"; +>m3 : Symbol(m3, Decl(index.cjs, 3, 6)) + +import * as m4 from "./subfolder/index.js"; +>m4 : Symbol(m4, Decl(index.cjs, 4, 6)) + +import * as m5 from "./subfolder/index.mjs"; +>m5 : Symbol(m5, Decl(index.cjs, 5, 6)) + +import * as m6 from "./subfolder/index.cjs"; +>m6 : Symbol(m6, Decl(index.cjs, 6, 6)) + +import * as m7 from "./subfolder2/index.js"; +>m7 : Symbol(m7, Decl(index.cjs, 7, 6)) + +import * as m8 from "./subfolder2/index.mjs"; +>m8 : Symbol(m8, Decl(index.cjs, 8, 6)) + +import * as m9 from "./subfolder2/index.cjs"; +>m9 : Symbol(m9, Decl(index.cjs, 9, 6)) + +import * as m10 from "./subfolder2/another/index.js"; +>m10 : Symbol(m10, Decl(index.cjs, 10, 6)) + +import * as m11 from "./subfolder2/another/index.mjs"; +>m11 : Symbol(m11, Decl(index.cjs, 11, 6)) + +import * as m12 from "./subfolder2/another/index.cjs"; +>m12 : Symbol(m12, Decl(index.cjs, 12, 6)) + +void m1; +>m1 : Symbol(m1, Decl(index.cjs, 1, 6)) + +void m2; +>m2 : Symbol(m2, Decl(index.cjs, 2, 6)) + +void m3; +>m3 : Symbol(m3, Decl(index.cjs, 3, 6)) + +void m4; +>m4 : Symbol(m4, Decl(index.cjs, 4, 6)) + +void m5; +>m5 : Symbol(m5, Decl(index.cjs, 5, 6)) + +void m6; +>m6 : Symbol(m6, Decl(index.cjs, 6, 6)) + +void m7; +>m7 : Symbol(m7, Decl(index.cjs, 7, 6)) + +void m8; +>m8 : Symbol(m8, Decl(index.cjs, 8, 6)) + +void m9; +>m9 : Symbol(m9, Decl(index.cjs, 9, 6)) + +void m10; +>m10 : Symbol(m10, Decl(index.cjs, 10, 6)) + +void m11; +>m11 : Symbol(m11, Decl(index.cjs, 11, 6)) + +void m12; +>m12 : Symbol(m12, Decl(index.cjs, 12, 6)) + +// cjs format file +const x = 1; +>x : Symbol(x, Decl(index.cjs, 26, 5)) + +export {x}; +>x : Symbol(m3.x, Decl(index.cjs, 27, 8)) + +=== tests/cases/conformance/node/allowJs/index.mjs === +import * as m1 from "./index.js"; +>m1 : Symbol(m1, Decl(index.mjs, 0, 6)) + +import * as m2 from "./index.mjs"; +>m2 : Symbol(m2, Decl(index.mjs, 1, 6)) + +import * as m3 from "./index.cjs"; +>m3 : Symbol(m3, Decl(index.mjs, 2, 6)) + +import * as m4 from "./subfolder/index.js"; +>m4 : Symbol(m4, Decl(index.mjs, 3, 6)) + +import * as m5 from "./subfolder/index.mjs"; +>m5 : Symbol(m5, Decl(index.mjs, 4, 6)) + +import * as m6 from "./subfolder/index.cjs"; +>m6 : Symbol(m6, Decl(index.mjs, 5, 6)) + +import * as m7 from "./subfolder2/index.js"; +>m7 : Symbol(m7, Decl(index.mjs, 6, 6)) + +import * as m8 from "./subfolder2/index.mjs"; +>m8 : Symbol(m8, Decl(index.mjs, 7, 6)) + +import * as m9 from "./subfolder2/index.cjs"; +>m9 : Symbol(m9, Decl(index.mjs, 8, 6)) + +import * as m10 from "./subfolder2/another/index.js"; +>m10 : Symbol(m10, Decl(index.mjs, 9, 6)) + +import * as m11 from "./subfolder2/another/index.mjs"; +>m11 : Symbol(m11, Decl(index.mjs, 10, 6)) + +import * as m12 from "./subfolder2/another/index.cjs"; +>m12 : Symbol(m12, Decl(index.mjs, 11, 6)) + +void m1; +>m1 : Symbol(m1, Decl(index.mjs, 0, 6)) + +void m2; +>m2 : Symbol(m2, Decl(index.mjs, 1, 6)) + +void m3; +>m3 : Symbol(m3, Decl(index.mjs, 2, 6)) + +void m4; +>m4 : Symbol(m4, Decl(index.mjs, 3, 6)) + +void m5; +>m5 : Symbol(m5, Decl(index.mjs, 4, 6)) + +void m6; +>m6 : Symbol(m6, Decl(index.mjs, 5, 6)) + +void m7; +>m7 : Symbol(m7, Decl(index.mjs, 6, 6)) + +void m8; +>m8 : Symbol(m8, Decl(index.mjs, 7, 6)) + +void m9; +>m9 : Symbol(m9, Decl(index.mjs, 8, 6)) + +void m10; +>m10 : Symbol(m10, Decl(index.mjs, 9, 6)) + +void m11; +>m11 : Symbol(m11, Decl(index.mjs, 10, 6)) + +void m12; +>m12 : Symbol(m12, Decl(index.mjs, 11, 6)) + +// esm format file +const x = 1; +>x : Symbol(x, Decl(index.mjs, 25, 5)) + +export {x}; +>x : Symbol(m2.x, Decl(index.mjs, 26, 8)) diff --git a/tests/baselines/reference/nodeModulesAllowJs1(module=node12).types b/tests/baselines/reference/nodeModulesAllowJs1(module=node12).types index bb0713313ec99..d0acce4132567 100644 --- a/tests/baselines/reference/nodeModulesAllowJs1(module=node12).types +++ b/tests/baselines/reference/nodeModulesAllowJs1(module=node12).types @@ -7,6 +7,24 @@ const x = 1; export {x}; >x : 1 +=== tests/cases/conformance/node/allowJs/subfolder/index.cjs === +// cjs format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + +=== tests/cases/conformance/node/allowJs/subfolder/index.mjs === +// esm format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + === tests/cases/conformance/node/allowJs/subfolder2/index.js === // cjs format file const x = 1; @@ -16,6 +34,24 @@ const x = 1; export {x}; >x : 1 +=== tests/cases/conformance/node/allowJs/subfolder2/index.cjs === +// cjs format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + +=== tests/cases/conformance/node/allowJs/subfolder2/index.mjs === +// esm format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + === tests/cases/conformance/node/allowJs/subfolder2/another/index.js === // esm format file const x = 1; @@ -25,7 +61,296 @@ const x = 1; export {x}; >x : 1 +=== tests/cases/conformance/node/allowJs/subfolder2/another/index.cjs === +// cjs format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + +=== tests/cases/conformance/node/allowJs/subfolder2/another/index.mjs === +// esm format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + === tests/cases/conformance/node/allowJs/index.js === +import * as m1 from "./index.js"; +>m1 : typeof m1 + +import * as m2 from "./index.mjs"; +>m2 : typeof m2 + +import * as m3 from "./index.cjs"; +>m3 : typeof m3 + +import * as m4 from "./subfolder/index.js"; +>m4 : typeof m4 + +import * as m5 from "./subfolder/index.mjs"; +>m5 : typeof m5 + +import * as m6 from "./subfolder/index.cjs"; +>m6 : typeof m6 + +import * as m7 from "./subfolder2/index.js"; +>m7 : typeof m7 + +import * as m8 from "./subfolder2/index.mjs"; +>m8 : typeof m8 + +import * as m9 from "./subfolder2/index.cjs"; +>m9 : typeof m9 + +import * as m10 from "./subfolder2/another/index.js"; +>m10 : typeof m10 + +import * as m11 from "./subfolder2/another/index.mjs"; +>m11 : typeof m11 + +import * as m12 from "./subfolder2/another/index.cjs"; +>m12 : typeof m12 + +void m1; +>void m1 : undefined +>m1 : typeof m1 + +void m2; +>void m2 : undefined +>m2 : typeof m2 + +void m3; +>void m3 : undefined +>m3 : typeof m3 + +void m4; +>void m4 : undefined +>m4 : typeof m4 + +void m5; +>void m5 : undefined +>m5 : typeof m5 + +void m6; +>void m6 : undefined +>m6 : typeof m6 + +void m7; +>void m7 : undefined +>m7 : typeof m7 + +void m8; +>void m8 : undefined +>m8 : typeof m8 + +void m9; +>void m9 : undefined +>m9 : typeof m9 + +void m10; +>void m10 : undefined +>m10 : typeof m10 + +void m11; +>void m11 : undefined +>m11 : typeof m11 + +void m12; +>void m12 : undefined +>m12 : typeof m12 + +// esm format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + +=== tests/cases/conformance/node/allowJs/index.cjs === +// ESM format imports below should error +import * as m1 from "./index.js"; +>m1 : typeof m1 + +import * as m2 from "./index.mjs"; +>m2 : typeof m2 + +import * as m3 from "./index.cjs"; +>m3 : typeof m3 + +import * as m4 from "./subfolder/index.js"; +>m4 : typeof m4 + +import * as m5 from "./subfolder/index.mjs"; +>m5 : typeof m5 + +import * as m6 from "./subfolder/index.cjs"; +>m6 : typeof m6 + +import * as m7 from "./subfolder2/index.js"; +>m7 : typeof m7 + +import * as m8 from "./subfolder2/index.mjs"; +>m8 : typeof m8 + +import * as m9 from "./subfolder2/index.cjs"; +>m9 : typeof m9 + +import * as m10 from "./subfolder2/another/index.js"; +>m10 : typeof m10 + +import * as m11 from "./subfolder2/another/index.mjs"; +>m11 : typeof m11 + +import * as m12 from "./subfolder2/another/index.cjs"; +>m12 : typeof m12 + +void m1; +>void m1 : undefined +>m1 : typeof m1 + +void m2; +>void m2 : undefined +>m2 : typeof m2 + +void m3; +>void m3 : undefined +>m3 : typeof m3 + +void m4; +>void m4 : undefined +>m4 : typeof m4 + +void m5; +>void m5 : undefined +>m5 : typeof m5 + +void m6; +>void m6 : undefined +>m6 : typeof m6 + +void m7; +>void m7 : undefined +>m7 : typeof m7 + +void m8; +>void m8 : undefined +>m8 : typeof m8 + +void m9; +>void m9 : undefined +>m9 : typeof m9 + +void m10; +>void m10 : undefined +>m10 : typeof m10 + +void m11; +>void m11 : undefined +>m11 : typeof m11 + +void m12; +>void m12 : undefined +>m12 : typeof m12 + +// cjs format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + +=== tests/cases/conformance/node/allowJs/index.mjs === +import * as m1 from "./index.js"; +>m1 : typeof m1 + +import * as m2 from "./index.mjs"; +>m2 : typeof m2 + +import * as m3 from "./index.cjs"; +>m3 : typeof m3 + +import * as m4 from "./subfolder/index.js"; +>m4 : typeof m4 + +import * as m5 from "./subfolder/index.mjs"; +>m5 : typeof m5 + +import * as m6 from "./subfolder/index.cjs"; +>m6 : typeof m6 + +import * as m7 from "./subfolder2/index.js"; +>m7 : typeof m7 + +import * as m8 from "./subfolder2/index.mjs"; +>m8 : typeof m8 + +import * as m9 from "./subfolder2/index.cjs"; +>m9 : typeof m9 + +import * as m10 from "./subfolder2/another/index.js"; +>m10 : typeof m10 + +import * as m11 from "./subfolder2/another/index.mjs"; +>m11 : typeof m11 + +import * as m12 from "./subfolder2/another/index.cjs"; +>m12 : typeof m12 + +void m1; +>void m1 : undefined +>m1 : typeof m1 + +void m2; +>void m2 : undefined +>m2 : typeof m2 + +void m3; +>void m3 : undefined +>m3 : typeof m3 + +void m4; +>void m4 : undefined +>m4 : typeof m4 + +void m5; +>void m5 : undefined +>m5 : typeof m5 + +void m6; +>void m6 : undefined +>m6 : typeof m6 + +void m7; +>void m7 : undefined +>m7 : typeof m7 + +void m8; +>void m8 : undefined +>m8 : typeof m8 + +void m9; +>void m9 : undefined +>m9 : typeof m9 + +void m10; +>void m10 : undefined +>m10 : typeof m10 + +void m11; +>void m11 : undefined +>m11 : typeof m11 + +void m12; +>void m12 : undefined +>m12 : typeof m12 + // esm format file const x = 1; >x : 1 diff --git a/tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).errors.txt new file mode 100644 index 0000000000000..d2d1c33f60189 --- /dev/null +++ b/tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).errors.txt @@ -0,0 +1,158 @@ +tests/cases/conformance/node/allowJs/index.cjs(2,21): error TS1435: Module './index.js' 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(3,21): error TS1435: Module './index.mjs' 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(6,21): error TS1435: Module './subfolder/index.mjs' 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(9,21): error TS1435: Module './subfolder2/index.mjs' 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(11,22): error TS1435: Module './subfolder2/another/index.js' 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(12,22): error TS1435: Module './subfolder2/another/index.mjs' 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/subfolder/index.js (0 errors) ==== + // cjs format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/allowJs/subfolder/index.cjs (0 errors) ==== + // cjs format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/allowJs/subfolder/index.mjs (0 errors) ==== + // esm format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/allowJs/subfolder2/index.js (0 errors) ==== + // cjs format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/allowJs/subfolder2/index.cjs (0 errors) ==== + // cjs format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/allowJs/subfolder2/index.mjs (0 errors) ==== + // esm format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/allowJs/subfolder2/another/index.js (0 errors) ==== + // esm format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/allowJs/subfolder2/another/index.cjs (0 errors) ==== + // cjs format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/allowJs/subfolder2/another/index.mjs (0 errors) ==== + // esm format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/allowJs/index.js (0 errors) ==== + import * as m1 from "./index.js"; + import * as m2 from "./index.mjs"; + import * as m3 from "./index.cjs"; + import * as m4 from "./subfolder/index.js"; + import * as m5 from "./subfolder/index.mjs"; + import * as m6 from "./subfolder/index.cjs"; + import * as m7 from "./subfolder2/index.js"; + import * as m8 from "./subfolder2/index.mjs"; + import * as m9 from "./subfolder2/index.cjs"; + import * as m10 from "./subfolder2/another/index.js"; + import * as m11 from "./subfolder2/another/index.mjs"; + import * as m12 from "./subfolder2/another/index.cjs"; + void m1; + void m2; + void m3; + void m4; + void m5; + void m6; + void m7; + void m8; + void m9; + void m10; + void m11; + void m12; + // esm format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/allowJs/index.cjs (6 errors) ==== + // ESM format imports below should error + import * as m1 from "./index.js"; + ~~~~~~~~~~~~ +!!! error TS1435: Module './index.js' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. + import * as m2 from "./index.mjs"; + ~~~~~~~~~~~~~ +!!! error TS1435: Module './index.mjs' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. + import * as m3 from "./index.cjs"; + import * as m4 from "./subfolder/index.js"; + import * as m5 from "./subfolder/index.mjs"; + ~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1435: Module './subfolder/index.mjs' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. + import * as m6 from "./subfolder/index.cjs"; + import * as m7 from "./subfolder2/index.js"; + import * as m8 from "./subfolder2/index.mjs"; + ~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1435: Module './subfolder2/index.mjs' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. + import * as m9 from "./subfolder2/index.cjs"; + import * as m10 from "./subfolder2/another/index.js"; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1435: Module './subfolder2/another/index.js' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. + import * as m11 from "./subfolder2/another/index.mjs"; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1435: Module './subfolder2/another/index.mjs' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. + import * as m12 from "./subfolder2/another/index.cjs"; + void m1; + void m2; + void m3; + void m4; + void m5; + void m6; + void m7; + void m8; + void m9; + void m10; + void m11; + void m12; + // cjs format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/allowJs/index.mjs (0 errors) ==== + import * as m1 from "./index.js"; + import * as m2 from "./index.mjs"; + import * as m3 from "./index.cjs"; + import * as m4 from "./subfolder/index.js"; + import * as m5 from "./subfolder/index.mjs"; + import * as m6 from "./subfolder/index.cjs"; + import * as m7 from "./subfolder2/index.js"; + import * as m8 from "./subfolder2/index.mjs"; + import * as m9 from "./subfolder2/index.cjs"; + import * as m10 from "./subfolder2/another/index.js"; + import * as m11 from "./subfolder2/another/index.mjs"; + import * as m12 from "./subfolder2/another/index.cjs"; + void m1; + void m2; + void m3; + void m4; + void m5; + void m6; + void m7; + void m8; + void m9; + void m10; + void m11; + void m12; + // esm format file + const x = 1; + export {x}; +==== tests/cases/conformance/node/allowJs/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module" + } +==== tests/cases/conformance/node/allowJs/subfolder/package.json (0 errors) ==== + { + "type": "commonjs" + } +==== tests/cases/conformance/node/allowJs/subfolder2/package.json (0 errors) ==== + { + } +==== tests/cases/conformance/node/allowJs/subfolder2/another/package.json (0 errors) ==== + { + "type": "module" + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).js b/tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).js index 358104e5f6a62..0ec674cdd18b3 100644 --- a/tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).js +++ b/tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).js @@ -4,15 +4,120 @@ // cjs format file const x = 1; export {x}; +//// [index.cjs] +// cjs format file +const x = 1; +export {x}; +//// [index.mjs] +// esm format file +const x = 1; +export {x}; //// [index.js] // cjs format file const x = 1; export {x}; +//// [index.cjs] +// cjs format file +const x = 1; +export {x}; +//// [index.mjs] +// esm format file +const x = 1; +export {x}; //// [index.js] // esm format file const x = 1; export {x}; +//// [index.cjs] +// cjs format file +const x = 1; +export {x}; +//// [index.mjs] +// esm format file +const x = 1; +export {x}; //// [index.js] +import * as m1 from "./index.js"; +import * as m2 from "./index.mjs"; +import * as m3 from "./index.cjs"; +import * as m4 from "./subfolder/index.js"; +import * as m5 from "./subfolder/index.mjs"; +import * as m6 from "./subfolder/index.cjs"; +import * as m7 from "./subfolder2/index.js"; +import * as m8 from "./subfolder2/index.mjs"; +import * as m9 from "./subfolder2/index.cjs"; +import * as m10 from "./subfolder2/another/index.js"; +import * as m11 from "./subfolder2/another/index.mjs"; +import * as m12 from "./subfolder2/another/index.cjs"; +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; +// esm format file +const x = 1; +export {x}; +//// [index.cjs] +// ESM format imports below should error +import * as m1 from "./index.js"; +import * as m2 from "./index.mjs"; +import * as m3 from "./index.cjs"; +import * as m4 from "./subfolder/index.js"; +import * as m5 from "./subfolder/index.mjs"; +import * as m6 from "./subfolder/index.cjs"; +import * as m7 from "./subfolder2/index.js"; +import * as m8 from "./subfolder2/index.mjs"; +import * as m9 from "./subfolder2/index.cjs"; +import * as m10 from "./subfolder2/another/index.js"; +import * as m11 from "./subfolder2/another/index.mjs"; +import * as m12 from "./subfolder2/another/index.cjs"; +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; +// cjs format file +const x = 1; +export {x}; +//// [index.mjs] +import * as m1 from "./index.js"; +import * as m2 from "./index.mjs"; +import * as m3 from "./index.cjs"; +import * as m4 from "./subfolder/index.js"; +import * as m5 from "./subfolder/index.mjs"; +import * as m6 from "./subfolder/index.cjs"; +import * as m7 from "./subfolder2/index.js"; +import * as m8 from "./subfolder2/index.mjs"; +import * as m9 from "./subfolder2/index.cjs"; +import * as m10 from "./subfolder2/another/index.js"; +import * as m11 from "./subfolder2/another/index.mjs"; +import * as m12 from "./subfolder2/another/index.cjs"; +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; // esm format file const x = 1; export {x}; @@ -41,6 +146,17 @@ exports.x = void 0; // cjs format file const x = 1; exports.x = x; +//// [index.cjs] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +// cjs format file +const x = 1; +exports.x = x; +//// [index.mjs] +// esm format file +const x = 1; +export { x }; //// [index.js] "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); @@ -48,11 +164,136 @@ exports.x = void 0; // cjs format file const x = 1; exports.x = x; +//// [index.cjs] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +// cjs format file +const x = 1; +exports.x = x; +//// [index.mjs] +// esm format file +const x = 1; +export { x }; //// [index.js] // esm format file const x = 1; export { x }; +//// [index.cjs] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +// cjs format file +const x = 1; +exports.x = x; +//// [index.mjs] +// esm format file +const x = 1; +export { x }; +//// [index.cjs] +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +// ESM format imports below should error +const m1 = __importStar(require("./index.js")); +const m2 = __importStar(require("./index.mjs")); +const m3 = __importStar(require("./index.cjs")); +const m4 = __importStar(require("./subfolder/index.js")); +const m5 = __importStar(require("./subfolder/index.mjs")); +const m6 = __importStar(require("./subfolder/index.cjs")); +const m7 = __importStar(require("./subfolder2/index.js")); +const m8 = __importStar(require("./subfolder2/index.mjs")); +const m9 = __importStar(require("./subfolder2/index.cjs")); +const m10 = __importStar(require("./subfolder2/another/index.js")); +const m11 = __importStar(require("./subfolder2/another/index.mjs")); +const m12 = __importStar(require("./subfolder2/another/index.cjs")); +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; +// cjs format file +const x = 1; +exports.x = x; +//// [index.mjs] +import * as m1 from "./index.js"; +import * as m2 from "./index.mjs"; +import * as m3 from "./index.cjs"; +import * as m4 from "./subfolder/index.js"; +import * as m5 from "./subfolder/index.mjs"; +import * as m6 from "./subfolder/index.cjs"; +import * as m7 from "./subfolder2/index.js"; +import * as m8 from "./subfolder2/index.mjs"; +import * as m9 from "./subfolder2/index.cjs"; +import * as m10 from "./subfolder2/another/index.js"; +import * as m11 from "./subfolder2/another/index.mjs"; +import * as m12 from "./subfolder2/another/index.cjs"; +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; +// esm format file +const x = 1; +export { x }; //// [index.js] +import * as m1 from "./index.js"; +import * as m2 from "./index.mjs"; +import * as m3 from "./index.cjs"; +import * as m4 from "./subfolder/index.js"; +import * as m5 from "./subfolder/index.mjs"; +import * as m6 from "./subfolder/index.cjs"; +import * as m7 from "./subfolder2/index.js"; +import * as m8 from "./subfolder2/index.mjs"; +import * as m9 from "./subfolder2/index.cjs"; +import * as m10 from "./subfolder2/another/index.js"; +import * as m11 from "./subfolder2/another/index.mjs"; +import * as m12 from "./subfolder2/another/index.cjs"; +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; // esm format file const x = 1; export { x }; @@ -60,9 +301,33 @@ export { x }; //// [index.d.ts] export const x: 1; +//// [index.d.cts] +declare const x = 1; +export { x }; +//// [index.d.mts] +declare const x = 1; +export { x }; //// [index.d.ts] export const x: 1; +//// [index.d.cts] +declare const x = 1; +export { x }; +//// [index.d.mts] +declare const x = 1; +export { x }; //// [index.d.ts] export const x: 1; +//// [index.d.cts] +declare const x = 1; +export { x }; +//// [index.d.mts] +declare const x = 1; +export { x }; +//// [index.d.cts] +declare const x = 1; +export { x }; +//// [index.d.mts] +declare const x = 1; +export { x }; //// [index.d.ts] export const x: 1; diff --git a/tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).symbols b/tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).symbols index 99bfb2a40ff73..90c86e3a1be64 100644 --- a/tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).symbols +++ b/tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).symbols @@ -6,6 +6,22 @@ const x = 1; export {x}; >x : Symbol(x, Decl(index.js, 2, 8)) +=== tests/cases/conformance/node/allowJs/subfolder/index.cjs === +// cjs format file +const x = 1; +>x : Symbol(x, Decl(index.cjs, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.cjs, 2, 8)) + +=== tests/cases/conformance/node/allowJs/subfolder/index.mjs === +// esm format file +const x = 1; +>x : Symbol(x, Decl(index.mjs, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.mjs, 2, 8)) + === tests/cases/conformance/node/allowJs/subfolder2/index.js === // cjs format file const x = 1; @@ -14,6 +30,22 @@ const x = 1; export {x}; >x : Symbol(x, Decl(index.js, 2, 8)) +=== tests/cases/conformance/node/allowJs/subfolder2/index.cjs === +// cjs format file +const x = 1; +>x : Symbol(x, Decl(index.cjs, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.cjs, 2, 8)) + +=== tests/cases/conformance/node/allowJs/subfolder2/index.mjs === +// esm format file +const x = 1; +>x : Symbol(x, Decl(index.mjs, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.mjs, 2, 8)) + === tests/cases/conformance/node/allowJs/subfolder2/another/index.js === // esm format file const x = 1; @@ -22,11 +54,260 @@ const x = 1; export {x}; >x : Symbol(x, Decl(index.js, 2, 8)) +=== tests/cases/conformance/node/allowJs/subfolder2/another/index.cjs === +// cjs format file +const x = 1; +>x : Symbol(x, Decl(index.cjs, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.cjs, 2, 8)) + +=== tests/cases/conformance/node/allowJs/subfolder2/another/index.mjs === +// esm format file +const x = 1; +>x : Symbol(x, Decl(index.mjs, 1, 5)) + +export {x}; +>x : Symbol(x, Decl(index.mjs, 2, 8)) + === tests/cases/conformance/node/allowJs/index.js === +import * as m1 from "./index.js"; +>m1 : Symbol(m1, Decl(index.js, 0, 6)) + +import * as m2 from "./index.mjs"; +>m2 : Symbol(m2, Decl(index.js, 1, 6)) + +import * as m3 from "./index.cjs"; +>m3 : Symbol(m3, Decl(index.js, 2, 6)) + +import * as m4 from "./subfolder/index.js"; +>m4 : Symbol(m4, Decl(index.js, 3, 6)) + +import * as m5 from "./subfolder/index.mjs"; +>m5 : Symbol(m5, Decl(index.js, 4, 6)) + +import * as m6 from "./subfolder/index.cjs"; +>m6 : Symbol(m6, Decl(index.js, 5, 6)) + +import * as m7 from "./subfolder2/index.js"; +>m7 : Symbol(m7, Decl(index.js, 6, 6)) + +import * as m8 from "./subfolder2/index.mjs"; +>m8 : Symbol(m8, Decl(index.js, 7, 6)) + +import * as m9 from "./subfolder2/index.cjs"; +>m9 : Symbol(m9, Decl(index.js, 8, 6)) + +import * as m10 from "./subfolder2/another/index.js"; +>m10 : Symbol(m10, Decl(index.js, 9, 6)) + +import * as m11 from "./subfolder2/another/index.mjs"; +>m11 : Symbol(m11, Decl(index.js, 10, 6)) + +import * as m12 from "./subfolder2/another/index.cjs"; +>m12 : Symbol(m12, Decl(index.js, 11, 6)) + +void m1; +>m1 : Symbol(m1, Decl(index.js, 0, 6)) + +void m2; +>m2 : Symbol(m2, Decl(index.js, 1, 6)) + +void m3; +>m3 : Symbol(m3, Decl(index.js, 2, 6)) + +void m4; +>m4 : Symbol(m4, Decl(index.js, 3, 6)) + +void m5; +>m5 : Symbol(m5, Decl(index.js, 4, 6)) + +void m6; +>m6 : Symbol(m6, Decl(index.js, 5, 6)) + +void m7; +>m7 : Symbol(m7, Decl(index.js, 6, 6)) + +void m8; +>m8 : Symbol(m8, Decl(index.js, 7, 6)) + +void m9; +>m9 : Symbol(m9, Decl(index.js, 8, 6)) + +void m10; +>m10 : Symbol(m10, Decl(index.js, 9, 6)) + +void m11; +>m11 : Symbol(m11, Decl(index.js, 10, 6)) + +void m12; +>m12 : Symbol(m12, Decl(index.js, 11, 6)) + // esm format file const x = 1; ->x : Symbol(x, Decl(index.js, 1, 5)) +>x : Symbol(x, Decl(index.js, 25, 5)) export {x}; ->x : Symbol(x, Decl(index.js, 2, 8)) +>x : Symbol(m1.x, Decl(index.js, 26, 8)) + +=== tests/cases/conformance/node/allowJs/index.cjs === +// ESM format imports below should error +import * as m1 from "./index.js"; +>m1 : Symbol(m1, Decl(index.cjs, 1, 6)) + +import * as m2 from "./index.mjs"; +>m2 : Symbol(m2, Decl(index.cjs, 2, 6)) + +import * as m3 from "./index.cjs"; +>m3 : Symbol(m3, Decl(index.cjs, 3, 6)) + +import * as m4 from "./subfolder/index.js"; +>m4 : Symbol(m4, Decl(index.cjs, 4, 6)) + +import * as m5 from "./subfolder/index.mjs"; +>m5 : Symbol(m5, Decl(index.cjs, 5, 6)) + +import * as m6 from "./subfolder/index.cjs"; +>m6 : Symbol(m6, Decl(index.cjs, 6, 6)) + +import * as m7 from "./subfolder2/index.js"; +>m7 : Symbol(m7, Decl(index.cjs, 7, 6)) + +import * as m8 from "./subfolder2/index.mjs"; +>m8 : Symbol(m8, Decl(index.cjs, 8, 6)) + +import * as m9 from "./subfolder2/index.cjs"; +>m9 : Symbol(m9, Decl(index.cjs, 9, 6)) + +import * as m10 from "./subfolder2/another/index.js"; +>m10 : Symbol(m10, Decl(index.cjs, 10, 6)) + +import * as m11 from "./subfolder2/another/index.mjs"; +>m11 : Symbol(m11, Decl(index.cjs, 11, 6)) + +import * as m12 from "./subfolder2/another/index.cjs"; +>m12 : Symbol(m12, Decl(index.cjs, 12, 6)) + +void m1; +>m1 : Symbol(m1, Decl(index.cjs, 1, 6)) + +void m2; +>m2 : Symbol(m2, Decl(index.cjs, 2, 6)) + +void m3; +>m3 : Symbol(m3, Decl(index.cjs, 3, 6)) + +void m4; +>m4 : Symbol(m4, Decl(index.cjs, 4, 6)) + +void m5; +>m5 : Symbol(m5, Decl(index.cjs, 5, 6)) + +void m6; +>m6 : Symbol(m6, Decl(index.cjs, 6, 6)) + +void m7; +>m7 : Symbol(m7, Decl(index.cjs, 7, 6)) + +void m8; +>m8 : Symbol(m8, Decl(index.cjs, 8, 6)) + +void m9; +>m9 : Symbol(m9, Decl(index.cjs, 9, 6)) + +void m10; +>m10 : Symbol(m10, Decl(index.cjs, 10, 6)) + +void m11; +>m11 : Symbol(m11, Decl(index.cjs, 11, 6)) + +void m12; +>m12 : Symbol(m12, Decl(index.cjs, 12, 6)) + +// cjs format file +const x = 1; +>x : Symbol(x, Decl(index.cjs, 26, 5)) + +export {x}; +>x : Symbol(m3.x, Decl(index.cjs, 27, 8)) + +=== tests/cases/conformance/node/allowJs/index.mjs === +import * as m1 from "./index.js"; +>m1 : Symbol(m1, Decl(index.mjs, 0, 6)) + +import * as m2 from "./index.mjs"; +>m2 : Symbol(m2, Decl(index.mjs, 1, 6)) + +import * as m3 from "./index.cjs"; +>m3 : Symbol(m3, Decl(index.mjs, 2, 6)) + +import * as m4 from "./subfolder/index.js"; +>m4 : Symbol(m4, Decl(index.mjs, 3, 6)) + +import * as m5 from "./subfolder/index.mjs"; +>m5 : Symbol(m5, Decl(index.mjs, 4, 6)) + +import * as m6 from "./subfolder/index.cjs"; +>m6 : Symbol(m6, Decl(index.mjs, 5, 6)) + +import * as m7 from "./subfolder2/index.js"; +>m7 : Symbol(m7, Decl(index.mjs, 6, 6)) + +import * as m8 from "./subfolder2/index.mjs"; +>m8 : Symbol(m8, Decl(index.mjs, 7, 6)) + +import * as m9 from "./subfolder2/index.cjs"; +>m9 : Symbol(m9, Decl(index.mjs, 8, 6)) + +import * as m10 from "./subfolder2/another/index.js"; +>m10 : Symbol(m10, Decl(index.mjs, 9, 6)) + +import * as m11 from "./subfolder2/another/index.mjs"; +>m11 : Symbol(m11, Decl(index.mjs, 10, 6)) + +import * as m12 from "./subfolder2/another/index.cjs"; +>m12 : Symbol(m12, Decl(index.mjs, 11, 6)) + +void m1; +>m1 : Symbol(m1, Decl(index.mjs, 0, 6)) + +void m2; +>m2 : Symbol(m2, Decl(index.mjs, 1, 6)) + +void m3; +>m3 : Symbol(m3, Decl(index.mjs, 2, 6)) + +void m4; +>m4 : Symbol(m4, Decl(index.mjs, 3, 6)) + +void m5; +>m5 : Symbol(m5, Decl(index.mjs, 4, 6)) + +void m6; +>m6 : Symbol(m6, Decl(index.mjs, 5, 6)) + +void m7; +>m7 : Symbol(m7, Decl(index.mjs, 6, 6)) + +void m8; +>m8 : Symbol(m8, Decl(index.mjs, 7, 6)) + +void m9; +>m9 : Symbol(m9, Decl(index.mjs, 8, 6)) + +void m10; +>m10 : Symbol(m10, Decl(index.mjs, 9, 6)) + +void m11; +>m11 : Symbol(m11, Decl(index.mjs, 10, 6)) + +void m12; +>m12 : Symbol(m12, Decl(index.mjs, 11, 6)) + +// esm format file +const x = 1; +>x : Symbol(x, Decl(index.mjs, 25, 5)) + +export {x}; +>x : Symbol(m2.x, Decl(index.mjs, 26, 8)) diff --git a/tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).types b/tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).types index bb0713313ec99..d0acce4132567 100644 --- a/tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).types +++ b/tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).types @@ -7,6 +7,24 @@ const x = 1; export {x}; >x : 1 +=== tests/cases/conformance/node/allowJs/subfolder/index.cjs === +// cjs format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + +=== tests/cases/conformance/node/allowJs/subfolder/index.mjs === +// esm format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + === tests/cases/conformance/node/allowJs/subfolder2/index.js === // cjs format file const x = 1; @@ -16,6 +34,24 @@ const x = 1; export {x}; >x : 1 +=== tests/cases/conformance/node/allowJs/subfolder2/index.cjs === +// cjs format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + +=== tests/cases/conformance/node/allowJs/subfolder2/index.mjs === +// esm format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + === tests/cases/conformance/node/allowJs/subfolder2/another/index.js === // esm format file const x = 1; @@ -25,7 +61,296 @@ const x = 1; export {x}; >x : 1 +=== tests/cases/conformance/node/allowJs/subfolder2/another/index.cjs === +// cjs format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + +=== tests/cases/conformance/node/allowJs/subfolder2/another/index.mjs === +// esm format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + === tests/cases/conformance/node/allowJs/index.js === +import * as m1 from "./index.js"; +>m1 : typeof m1 + +import * as m2 from "./index.mjs"; +>m2 : typeof m2 + +import * as m3 from "./index.cjs"; +>m3 : typeof m3 + +import * as m4 from "./subfolder/index.js"; +>m4 : typeof m4 + +import * as m5 from "./subfolder/index.mjs"; +>m5 : typeof m5 + +import * as m6 from "./subfolder/index.cjs"; +>m6 : typeof m6 + +import * as m7 from "./subfolder2/index.js"; +>m7 : typeof m7 + +import * as m8 from "./subfolder2/index.mjs"; +>m8 : typeof m8 + +import * as m9 from "./subfolder2/index.cjs"; +>m9 : typeof m9 + +import * as m10 from "./subfolder2/another/index.js"; +>m10 : typeof m10 + +import * as m11 from "./subfolder2/another/index.mjs"; +>m11 : typeof m11 + +import * as m12 from "./subfolder2/another/index.cjs"; +>m12 : typeof m12 + +void m1; +>void m1 : undefined +>m1 : typeof m1 + +void m2; +>void m2 : undefined +>m2 : typeof m2 + +void m3; +>void m3 : undefined +>m3 : typeof m3 + +void m4; +>void m4 : undefined +>m4 : typeof m4 + +void m5; +>void m5 : undefined +>m5 : typeof m5 + +void m6; +>void m6 : undefined +>m6 : typeof m6 + +void m7; +>void m7 : undefined +>m7 : typeof m7 + +void m8; +>void m8 : undefined +>m8 : typeof m8 + +void m9; +>void m9 : undefined +>m9 : typeof m9 + +void m10; +>void m10 : undefined +>m10 : typeof m10 + +void m11; +>void m11 : undefined +>m11 : typeof m11 + +void m12; +>void m12 : undefined +>m12 : typeof m12 + +// esm format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + +=== tests/cases/conformance/node/allowJs/index.cjs === +// ESM format imports below should error +import * as m1 from "./index.js"; +>m1 : typeof m1 + +import * as m2 from "./index.mjs"; +>m2 : typeof m2 + +import * as m3 from "./index.cjs"; +>m3 : typeof m3 + +import * as m4 from "./subfolder/index.js"; +>m4 : typeof m4 + +import * as m5 from "./subfolder/index.mjs"; +>m5 : typeof m5 + +import * as m6 from "./subfolder/index.cjs"; +>m6 : typeof m6 + +import * as m7 from "./subfolder2/index.js"; +>m7 : typeof m7 + +import * as m8 from "./subfolder2/index.mjs"; +>m8 : typeof m8 + +import * as m9 from "./subfolder2/index.cjs"; +>m9 : typeof m9 + +import * as m10 from "./subfolder2/another/index.js"; +>m10 : typeof m10 + +import * as m11 from "./subfolder2/another/index.mjs"; +>m11 : typeof m11 + +import * as m12 from "./subfolder2/another/index.cjs"; +>m12 : typeof m12 + +void m1; +>void m1 : undefined +>m1 : typeof m1 + +void m2; +>void m2 : undefined +>m2 : typeof m2 + +void m3; +>void m3 : undefined +>m3 : typeof m3 + +void m4; +>void m4 : undefined +>m4 : typeof m4 + +void m5; +>void m5 : undefined +>m5 : typeof m5 + +void m6; +>void m6 : undefined +>m6 : typeof m6 + +void m7; +>void m7 : undefined +>m7 : typeof m7 + +void m8; +>void m8 : undefined +>m8 : typeof m8 + +void m9; +>void m9 : undefined +>m9 : typeof m9 + +void m10; +>void m10 : undefined +>m10 : typeof m10 + +void m11; +>void m11 : undefined +>m11 : typeof m11 + +void m12; +>void m12 : undefined +>m12 : typeof m12 + +// cjs format file +const x = 1; +>x : 1 +>1 : 1 + +export {x}; +>x : 1 + +=== tests/cases/conformance/node/allowJs/index.mjs === +import * as m1 from "./index.js"; +>m1 : typeof m1 + +import * as m2 from "./index.mjs"; +>m2 : typeof m2 + +import * as m3 from "./index.cjs"; +>m3 : typeof m3 + +import * as m4 from "./subfolder/index.js"; +>m4 : typeof m4 + +import * as m5 from "./subfolder/index.mjs"; +>m5 : typeof m5 + +import * as m6 from "./subfolder/index.cjs"; +>m6 : typeof m6 + +import * as m7 from "./subfolder2/index.js"; +>m7 : typeof m7 + +import * as m8 from "./subfolder2/index.mjs"; +>m8 : typeof m8 + +import * as m9 from "./subfolder2/index.cjs"; +>m9 : typeof m9 + +import * as m10 from "./subfolder2/another/index.js"; +>m10 : typeof m10 + +import * as m11 from "./subfolder2/another/index.mjs"; +>m11 : typeof m11 + +import * as m12 from "./subfolder2/another/index.cjs"; +>m12 : typeof m12 + +void m1; +>void m1 : undefined +>m1 : typeof m1 + +void m2; +>void m2 : undefined +>m2 : typeof m2 + +void m3; +>void m3 : undefined +>m3 : typeof m3 + +void m4; +>void m4 : undefined +>m4 : typeof m4 + +void m5; +>void m5 : undefined +>m5 : typeof m5 + +void m6; +>void m6 : undefined +>m6 : typeof m6 + +void m7; +>void m7 : undefined +>m7 : typeof m7 + +void m8; +>void m8 : undefined +>m8 : typeof m8 + +void m9; +>void m9 : undefined +>m9 : typeof m9 + +void m10; +>void m10 : undefined +>m10 : typeof m10 + +void m11; +>void m11 : undefined +>m11 : typeof m11 + +void m12; +>void m12 : undefined +>m12 : typeof m12 + // esm format file const x = 1; >x : 1 diff --git a/tests/baselines/reference/nodeModulesForbidenSyntax(module=node12).errors.txt b/tests/baselines/reference/nodeModulesForbidenSyntax(module=node12).errors.txt new file mode 100644 index 0000000000000..233fb07a30e11 --- /dev/null +++ b/tests/baselines/reference/nodeModulesForbidenSyntax(module=node12).errors.txt @@ -0,0 +1,139 @@ +tests/cases/conformance/node/index.cts(2,12): error TS7059: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. +tests/cases/conformance/node/index.cts(2,20): error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. +tests/cases/conformance/node/index.cts(2,23): error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. +tests/cases/conformance/node/index.mts(2,12): error TS7059: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. +tests/cases/conformance/node/index.mts(2,20): error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. +tests/cases/conformance/node/index.mts(2,23): error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder/index.cts(2,12): error TS7059: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. +tests/cases/conformance/node/subfolder/index.cts(2,20): error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder/index.cts(2,23): error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder/index.mts(2,12): error TS7059: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. +tests/cases/conformance/node/subfolder/index.mts(2,20): error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder/index.mts(2,23): error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder2/another/index.cts(2,12): error TS7059: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. +tests/cases/conformance/node/subfolder2/another/index.cts(2,20): error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder2/another/index.cts(2,23): error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder2/another/index.mts(2,12): error TS7059: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. +tests/cases/conformance/node/subfolder2/another/index.mts(2,20): error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder2/another/index.mts(2,23): error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder2/index.cts(2,12): error TS7059: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. +tests/cases/conformance/node/subfolder2/index.cts(2,20): error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder2/index.cts(2,23): error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder2/index.mts(2,12): error TS7059: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. +tests/cases/conformance/node/subfolder2/index.mts(2,20): error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder2/index.mts(2,23): error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. + + +==== tests/cases/conformance/node/subfolder/index.ts (0 errors) ==== + // cjs format file + const x = () => (void 0); + export {x}; +==== tests/cases/conformance/node/subfolder/index.cts (3 errors) ==== + // cjs format file + const x = () => (void 0); + ~ +!!! error TS7059: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. + ~~~~~~~~~~~~~~~~ +!!! error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. + ~~~~~~~~~~~~~ +!!! error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. + export {x}; +==== tests/cases/conformance/node/subfolder/index.mts (3 errors) ==== + // esm format file + const x = () => (void 0); + ~ +!!! error TS7059: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. + ~~~~~~~~~~~~~~~~ +!!! error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. + ~~~~~~~~~~~~~ +!!! error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. + export {x}; +==== tests/cases/conformance/node/subfolder2/index.ts (0 errors) ==== + // cjs format file + const x = () => (void 0); + export {x}; +==== tests/cases/conformance/node/subfolder2/index.cts (3 errors) ==== + // cjs format file + const x = () => (void 0); + ~ +!!! error TS7059: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. + ~~~~~~~~~~~~~~~~ +!!! error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. + ~~~~~~~~~~~~~ +!!! error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. + export {x}; +==== tests/cases/conformance/node/subfolder2/index.mts (3 errors) ==== + // esm format file + const x = () => (void 0); + ~ +!!! error TS7059: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. + ~~~~~~~~~~~~~~~~ +!!! error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. + ~~~~~~~~~~~~~ +!!! error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. + export {x}; +==== tests/cases/conformance/node/subfolder2/another/index.ts (0 errors) ==== + // esm format file + const x = () => (void 0); + export {x}; +==== tests/cases/conformance/node/subfolder2/another/index.mts (3 errors) ==== + // esm format file + const x = () => (void 0); + ~ +!!! error TS7059: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. + ~~~~~~~~~~~~~~~~ +!!! error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. + ~~~~~~~~~~~~~ +!!! error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. + export {x}; +==== tests/cases/conformance/node/subfolder2/another/index.cts (3 errors) ==== + // cjs format file + const x = () => (void 0); + ~ +!!! error TS7059: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. + ~~~~~~~~~~~~~~~~ +!!! error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. + ~~~~~~~~~~~~~ +!!! error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. + export {x}; +==== tests/cases/conformance/node/index.mts (3 errors) ==== + // esm format file + const x = () => (void 0); + ~ +!!! error TS7059: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. + ~~~~~~~~~~~~~~~~ +!!! error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. + ~~~~~~~~~~~~~ +!!! error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. + export {x}; +==== tests/cases/conformance/node/index.cts (3 errors) ==== + // cjs format file + const x = () => (void 0); + ~ +!!! error TS7059: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. + ~~~~~~~~~~~~~~~~ +!!! error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. + ~~~~~~~~~~~~~ +!!! error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. + export {x}; +==== tests/cases/conformance/node/index.ts (0 errors) ==== + // esm format file + const x = () => (void 0); + export {x}; +==== tests/cases/conformance/node/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module" + } +==== tests/cases/conformance/node/subfolder/package.json (0 errors) ==== + { + "type": "commonjs" + } +==== tests/cases/conformance/node/subfolder2/package.json (0 errors) ==== + { + } +==== tests/cases/conformance/node/subfolder2/another/package.json (0 errors) ==== + { + "type": "module" + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesForbidenSyntax(module=node12).js b/tests/baselines/reference/nodeModulesForbidenSyntax(module=node12).js new file mode 100644 index 0000000000000..4cca6af5a58d7 --- /dev/null +++ b/tests/baselines/reference/nodeModulesForbidenSyntax(module=node12).js @@ -0,0 +1,172 @@ +//// [tests/cases/conformance/node/nodeModulesForbidenSyntax.ts] //// + +//// [index.ts] +// cjs format file +const x = () => (void 0); +export {x}; +//// [index.cts] +// cjs format file +const x = () => (void 0); +export {x}; +//// [index.mts] +// esm format file +const x = () => (void 0); +export {x}; +//// [index.ts] +// cjs format file +const x = () => (void 0); +export {x}; +//// [index.cts] +// cjs format file +const x = () => (void 0); +export {x}; +//// [index.mts] +// esm format file +const x = () => (void 0); +export {x}; +//// [index.ts] +// esm format file +const x = () => (void 0); +export {x}; +//// [index.mts] +// esm format file +const x = () => (void 0); +export {x}; +//// [index.cts] +// cjs format file +const x = () => (void 0); +export {x}; +//// [index.mts] +// esm format file +const x = () => (void 0); +export {x}; +//// [index.cts] +// cjs format file +const x = () => (void 0); +export {x}; +//// [index.ts] +// esm format file +const x = () => (void 0); +export {x}; +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} +//// [package.json] +{ +} +//// [package.json] +{ + "type": "module" +} + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +// cjs format file +const x = () => (void 0); +exports.x = x; +//// [index.cjs] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +// cjs format file +const x = () => (void 0); +exports.x = x; +//// [index.mjs] +// esm format file +const x = () => (void 0); +export { x }; +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +// cjs format file +const x = () => (void 0); +exports.x = x; +//// [index.cjs] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +// cjs format file +const x = () => (void 0); +exports.x = x; +//// [index.mjs] +// esm format file +const x = () => (void 0); +export { x }; +//// [index.js] +// esm format file +const x = () => (void 0); +export { x }; +//// [index.mjs] +// esm format file +const x = () => (void 0); +export { x }; +//// [index.cjs] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +// cjs format file +const x = () => (void 0); +exports.x = x; +//// [index.mjs] +// esm format file +const x = () => (void 0); +export { x }; +//// [index.cjs] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +// cjs format file +const x = () => (void 0); +exports.x = x; +//// [index.js] +// esm format file +const x = () => (void 0); +export { x }; + + +//// [index.d.ts] +declare const x: () => T; +export { x }; +//// [index.d.cts] +declare const x: () => T; +export { x }; +//// [index.d.mts] +declare const x: () => T; +export { x }; +//// [index.d.ts] +declare const x: () => T; +export { x }; +//// [index.d.cts] +declare const x: () => T; +export { x }; +//// [index.d.mts] +declare const x: () => T; +export { x }; +//// [index.d.ts] +declare const x: () => T; +export { x }; +//// [index.d.mts] +declare const x: () => T; +export { x }; +//// [index.d.cts] +declare const x: () => T; +export { x }; +//// [index.d.mts] +declare const x: () => T; +export { x }; +//// [index.d.cts] +declare const x: () => T; +export { x }; +//// [index.d.ts] +declare const x: () => T; +export { x }; diff --git a/tests/baselines/reference/nodeModulesForbidenSyntax(module=node12).symbols b/tests/baselines/reference/nodeModulesForbidenSyntax(module=node12).symbols new file mode 100644 index 0000000000000..1ca35d0d3e32e --- /dev/null +++ b/tests/baselines/reference/nodeModulesForbidenSyntax(module=node12).symbols @@ -0,0 +1,120 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +const x = () => (void 0); +>x : Symbol(x, Decl(index.ts, 1, 5)) +>T : Symbol(T, Decl(index.ts, 1, 11)) +>T : Symbol(T, Decl(index.ts, 1, 11)) + +export {x}; +>x : Symbol(x, Decl(index.ts, 2, 8)) + +=== tests/cases/conformance/node/subfolder/index.cts === +// cjs format file +const x = () => (void 0); +>x : Symbol(x, Decl(index.cts, 1, 5)) +>T : Symbol(T, Decl(index.cts, 1, 11)) +>T : Symbol(T, Decl(index.cts, 1, 11)) + +export {x}; +>x : Symbol(x, Decl(index.cts, 2, 8)) + +=== tests/cases/conformance/node/subfolder/index.mts === +// esm format file +const x = () => (void 0); +>x : Symbol(x, Decl(index.mts, 1, 5)) +>T : Symbol(T, Decl(index.mts, 1, 11)) +>T : Symbol(T, Decl(index.mts, 1, 11)) + +export {x}; +>x : Symbol(x, Decl(index.mts, 2, 8)) + +=== tests/cases/conformance/node/subfolder2/index.ts === +// cjs format file +const x = () => (void 0); +>x : Symbol(x, Decl(index.ts, 1, 5)) +>T : Symbol(T, Decl(index.ts, 1, 11)) +>T : Symbol(T, Decl(index.ts, 1, 11)) + +export {x}; +>x : Symbol(x, Decl(index.ts, 2, 8)) + +=== tests/cases/conformance/node/subfolder2/index.cts === +// cjs format file +const x = () => (void 0); +>x : Symbol(x, Decl(index.cts, 1, 5)) +>T : Symbol(T, Decl(index.cts, 1, 11)) +>T : Symbol(T, Decl(index.cts, 1, 11)) + +export {x}; +>x : Symbol(x, Decl(index.cts, 2, 8)) + +=== tests/cases/conformance/node/subfolder2/index.mts === +// esm format file +const x = () => (void 0); +>x : Symbol(x, Decl(index.mts, 1, 5)) +>T : Symbol(T, Decl(index.mts, 1, 11)) +>T : Symbol(T, Decl(index.mts, 1, 11)) + +export {x}; +>x : Symbol(x, Decl(index.mts, 2, 8)) + +=== tests/cases/conformance/node/subfolder2/another/index.ts === +// esm format file +const x = () => (void 0); +>x : Symbol(x, Decl(index.ts, 1, 5)) +>T : Symbol(T, Decl(index.ts, 1, 11)) +>T : Symbol(T, Decl(index.ts, 1, 11)) + +export {x}; +>x : Symbol(x, Decl(index.ts, 2, 8)) + +=== tests/cases/conformance/node/subfolder2/another/index.mts === +// esm format file +const x = () => (void 0); +>x : Symbol(x, Decl(index.mts, 1, 5)) +>T : Symbol(T, Decl(index.mts, 1, 11)) +>T : Symbol(T, Decl(index.mts, 1, 11)) + +export {x}; +>x : Symbol(x, Decl(index.mts, 2, 8)) + +=== tests/cases/conformance/node/subfolder2/another/index.cts === +// cjs format file +const x = () => (void 0); +>x : Symbol(x, Decl(index.cts, 1, 5)) +>T : Symbol(T, Decl(index.cts, 1, 11)) +>T : Symbol(T, Decl(index.cts, 1, 11)) + +export {x}; +>x : Symbol(x, Decl(index.cts, 2, 8)) + +=== tests/cases/conformance/node/index.mts === +// esm format file +const x = () => (void 0); +>x : Symbol(x, Decl(index.mts, 1, 5)) +>T : Symbol(T, Decl(index.mts, 1, 11)) +>T : Symbol(T, Decl(index.mts, 1, 11)) + +export {x}; +>x : Symbol(x, Decl(index.mts, 2, 8)) + +=== tests/cases/conformance/node/index.cts === +// cjs format file +const x = () => (void 0); +>x : Symbol(x, Decl(index.cts, 1, 5)) +>T : Symbol(T, Decl(index.cts, 1, 11)) +>T : Symbol(T, Decl(index.cts, 1, 11)) + +export {x}; +>x : Symbol(x, Decl(index.cts, 2, 8)) + +=== tests/cases/conformance/node/index.ts === +// esm format file +const x = () => (void 0); +>x : Symbol(x, Decl(index.ts, 1, 5)) +>T : Symbol(T, Decl(index.ts, 1, 11)) +>T : Symbol(T, Decl(index.ts, 1, 11)) + +export {x}; +>x : Symbol(x, Decl(index.ts, 2, 8)) + diff --git a/tests/baselines/reference/nodeModulesForbidenSyntax(module=node12).types b/tests/baselines/reference/nodeModulesForbidenSyntax(module=node12).types new file mode 100644 index 0000000000000..016af4314d16b --- /dev/null +++ b/tests/baselines/reference/nodeModulesForbidenSyntax(module=node12).types @@ -0,0 +1,168 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +const x = () => (void 0); +>x : () => T +>() => (void 0) : () => T +>(void 0) : T +>(void 0) : any +>(void 0) : undefined +>void 0 : undefined +>0 : 0 + +export {x}; +>x : () => T + +=== tests/cases/conformance/node/subfolder/index.cts === +// cjs format file +const x = () => (void 0); +>x : () => T +>() => (void 0) : () => T +>(void 0) : T +>(void 0) : any +>(void 0) : undefined +>void 0 : undefined +>0 : 0 + +export {x}; +>x : () => T + +=== tests/cases/conformance/node/subfolder/index.mts === +// esm format file +const x = () => (void 0); +>x : () => T +>() => (void 0) : () => T +>(void 0) : T +>(void 0) : any +>(void 0) : undefined +>void 0 : undefined +>0 : 0 + +export {x}; +>x : () => T + +=== tests/cases/conformance/node/subfolder2/index.ts === +// cjs format file +const x = () => (void 0); +>x : () => T +>() => (void 0) : () => T +>(void 0) : T +>(void 0) : any +>(void 0) : undefined +>void 0 : undefined +>0 : 0 + +export {x}; +>x : () => T + +=== tests/cases/conformance/node/subfolder2/index.cts === +// cjs format file +const x = () => (void 0); +>x : () => T +>() => (void 0) : () => T +>(void 0) : T +>(void 0) : any +>(void 0) : undefined +>void 0 : undefined +>0 : 0 + +export {x}; +>x : () => T + +=== tests/cases/conformance/node/subfolder2/index.mts === +// esm format file +const x = () => (void 0); +>x : () => T +>() => (void 0) : () => T +>(void 0) : T +>(void 0) : any +>(void 0) : undefined +>void 0 : undefined +>0 : 0 + +export {x}; +>x : () => T + +=== tests/cases/conformance/node/subfolder2/another/index.ts === +// esm format file +const x = () => (void 0); +>x : () => T +>() => (void 0) : () => T +>(void 0) : T +>(void 0) : any +>(void 0) : undefined +>void 0 : undefined +>0 : 0 + +export {x}; +>x : () => T + +=== tests/cases/conformance/node/subfolder2/another/index.mts === +// esm format file +const x = () => (void 0); +>x : () => T +>() => (void 0) : () => T +>(void 0) : T +>(void 0) : any +>(void 0) : undefined +>void 0 : undefined +>0 : 0 + +export {x}; +>x : () => T + +=== tests/cases/conformance/node/subfolder2/another/index.cts === +// cjs format file +const x = () => (void 0); +>x : () => T +>() => (void 0) : () => T +>(void 0) : T +>(void 0) : any +>(void 0) : undefined +>void 0 : undefined +>0 : 0 + +export {x}; +>x : () => T + +=== tests/cases/conformance/node/index.mts === +// esm format file +const x = () => (void 0); +>x : () => T +>() => (void 0) : () => T +>(void 0) : T +>(void 0) : any +>(void 0) : undefined +>void 0 : undefined +>0 : 0 + +export {x}; +>x : () => T + +=== tests/cases/conformance/node/index.cts === +// cjs format file +const x = () => (void 0); +>x : () => T +>() => (void 0) : () => T +>(void 0) : T +>(void 0) : any +>(void 0) : undefined +>void 0 : undefined +>0 : 0 + +export {x}; +>x : () => T + +=== tests/cases/conformance/node/index.ts === +// esm format file +const x = () => (void 0); +>x : () => T +>() => (void 0) : () => T +>(void 0) : T +>(void 0) : any +>(void 0) : undefined +>void 0 : undefined +>0 : 0 + +export {x}; +>x : () => T + diff --git a/tests/baselines/reference/nodeModulesForbidenSyntax(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesForbidenSyntax(module=nodenext).errors.txt new file mode 100644 index 0000000000000..233fb07a30e11 --- /dev/null +++ b/tests/baselines/reference/nodeModulesForbidenSyntax(module=nodenext).errors.txt @@ -0,0 +1,139 @@ +tests/cases/conformance/node/index.cts(2,12): error TS7059: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. +tests/cases/conformance/node/index.cts(2,20): error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. +tests/cases/conformance/node/index.cts(2,23): error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. +tests/cases/conformance/node/index.mts(2,12): error TS7059: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. +tests/cases/conformance/node/index.mts(2,20): error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. +tests/cases/conformance/node/index.mts(2,23): error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder/index.cts(2,12): error TS7059: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. +tests/cases/conformance/node/subfolder/index.cts(2,20): error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder/index.cts(2,23): error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder/index.mts(2,12): error TS7059: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. +tests/cases/conformance/node/subfolder/index.mts(2,20): error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder/index.mts(2,23): error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder2/another/index.cts(2,12): error TS7059: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. +tests/cases/conformance/node/subfolder2/another/index.cts(2,20): error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder2/another/index.cts(2,23): error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder2/another/index.mts(2,12): error TS7059: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. +tests/cases/conformance/node/subfolder2/another/index.mts(2,20): error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder2/another/index.mts(2,23): error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder2/index.cts(2,12): error TS7059: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. +tests/cases/conformance/node/subfolder2/index.cts(2,20): error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder2/index.cts(2,23): error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder2/index.mts(2,12): error TS7059: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. +tests/cases/conformance/node/subfolder2/index.mts(2,20): error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder2/index.mts(2,23): error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. + + +==== tests/cases/conformance/node/subfolder/index.ts (0 errors) ==== + // cjs format file + const x = () => (void 0); + export {x}; +==== tests/cases/conformance/node/subfolder/index.cts (3 errors) ==== + // cjs format file + const x = () => (void 0); + ~ +!!! error TS7059: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. + ~~~~~~~~~~~~~~~~ +!!! error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. + ~~~~~~~~~~~~~ +!!! error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. + export {x}; +==== tests/cases/conformance/node/subfolder/index.mts (3 errors) ==== + // esm format file + const x = () => (void 0); + ~ +!!! error TS7059: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. + ~~~~~~~~~~~~~~~~ +!!! error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. + ~~~~~~~~~~~~~ +!!! error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. + export {x}; +==== tests/cases/conformance/node/subfolder2/index.ts (0 errors) ==== + // cjs format file + const x = () => (void 0); + export {x}; +==== tests/cases/conformance/node/subfolder2/index.cts (3 errors) ==== + // cjs format file + const x = () => (void 0); + ~ +!!! error TS7059: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. + ~~~~~~~~~~~~~~~~ +!!! error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. + ~~~~~~~~~~~~~ +!!! error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. + export {x}; +==== tests/cases/conformance/node/subfolder2/index.mts (3 errors) ==== + // esm format file + const x = () => (void 0); + ~ +!!! error TS7059: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. + ~~~~~~~~~~~~~~~~ +!!! error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. + ~~~~~~~~~~~~~ +!!! error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. + export {x}; +==== tests/cases/conformance/node/subfolder2/another/index.ts (0 errors) ==== + // esm format file + const x = () => (void 0); + export {x}; +==== tests/cases/conformance/node/subfolder2/another/index.mts (3 errors) ==== + // esm format file + const x = () => (void 0); + ~ +!!! error TS7059: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. + ~~~~~~~~~~~~~~~~ +!!! error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. + ~~~~~~~~~~~~~ +!!! error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. + export {x}; +==== tests/cases/conformance/node/subfolder2/another/index.cts (3 errors) ==== + // cjs format file + const x = () => (void 0); + ~ +!!! error TS7059: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. + ~~~~~~~~~~~~~~~~ +!!! error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. + ~~~~~~~~~~~~~ +!!! error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. + export {x}; +==== tests/cases/conformance/node/index.mts (3 errors) ==== + // esm format file + const x = () => (void 0); + ~ +!!! error TS7059: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. + ~~~~~~~~~~~~~~~~ +!!! error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. + ~~~~~~~~~~~~~ +!!! error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. + export {x}; +==== tests/cases/conformance/node/index.cts (3 errors) ==== + // cjs format file + const x = () => (void 0); + ~ +!!! error TS7059: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. + ~~~~~~~~~~~~~~~~ +!!! error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. + ~~~~~~~~~~~~~ +!!! error TS7058: This syntax is reserved in files with this extension. Use an `as` expression instead. + export {x}; +==== tests/cases/conformance/node/index.ts (0 errors) ==== + // esm format file + const x = () => (void 0); + export {x}; +==== tests/cases/conformance/node/package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module" + } +==== tests/cases/conformance/node/subfolder/package.json (0 errors) ==== + { + "type": "commonjs" + } +==== tests/cases/conformance/node/subfolder2/package.json (0 errors) ==== + { + } +==== tests/cases/conformance/node/subfolder2/another/package.json (0 errors) ==== + { + "type": "module" + } \ No newline at end of file diff --git a/tests/baselines/reference/nodeModulesForbidenSyntax(module=nodenext).js b/tests/baselines/reference/nodeModulesForbidenSyntax(module=nodenext).js new file mode 100644 index 0000000000000..4cca6af5a58d7 --- /dev/null +++ b/tests/baselines/reference/nodeModulesForbidenSyntax(module=nodenext).js @@ -0,0 +1,172 @@ +//// [tests/cases/conformance/node/nodeModulesForbidenSyntax.ts] //// + +//// [index.ts] +// cjs format file +const x = () => (void 0); +export {x}; +//// [index.cts] +// cjs format file +const x = () => (void 0); +export {x}; +//// [index.mts] +// esm format file +const x = () => (void 0); +export {x}; +//// [index.ts] +// cjs format file +const x = () => (void 0); +export {x}; +//// [index.cts] +// cjs format file +const x = () => (void 0); +export {x}; +//// [index.mts] +// esm format file +const x = () => (void 0); +export {x}; +//// [index.ts] +// esm format file +const x = () => (void 0); +export {x}; +//// [index.mts] +// esm format file +const x = () => (void 0); +export {x}; +//// [index.cts] +// cjs format file +const x = () => (void 0); +export {x}; +//// [index.mts] +// esm format file +const x = () => (void 0); +export {x}; +//// [index.cts] +// cjs format file +const x = () => (void 0); +export {x}; +//// [index.ts] +// esm format file +const x = () => (void 0); +export {x}; +//// [package.json] +{ + "name": "package", + "private": true, + "type": "module" +} +//// [package.json] +{ + "type": "commonjs" +} +//// [package.json] +{ +} +//// [package.json] +{ + "type": "module" +} + +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +// cjs format file +const x = () => (void 0); +exports.x = x; +//// [index.cjs] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +// cjs format file +const x = () => (void 0); +exports.x = x; +//// [index.mjs] +// esm format file +const x = () => (void 0); +export { x }; +//// [index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +// cjs format file +const x = () => (void 0); +exports.x = x; +//// [index.cjs] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +// cjs format file +const x = () => (void 0); +exports.x = x; +//// [index.mjs] +// esm format file +const x = () => (void 0); +export { x }; +//// [index.js] +// esm format file +const x = () => (void 0); +export { x }; +//// [index.mjs] +// esm format file +const x = () => (void 0); +export { x }; +//// [index.cjs] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +// cjs format file +const x = () => (void 0); +exports.x = x; +//// [index.mjs] +// esm format file +const x = () => (void 0); +export { x }; +//// [index.cjs] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.x = void 0; +// cjs format file +const x = () => (void 0); +exports.x = x; +//// [index.js] +// esm format file +const x = () => (void 0); +export { x }; + + +//// [index.d.ts] +declare const x: () => T; +export { x }; +//// [index.d.cts] +declare const x: () => T; +export { x }; +//// [index.d.mts] +declare const x: () => T; +export { x }; +//// [index.d.ts] +declare const x: () => T; +export { x }; +//// [index.d.cts] +declare const x: () => T; +export { x }; +//// [index.d.mts] +declare const x: () => T; +export { x }; +//// [index.d.ts] +declare const x: () => T; +export { x }; +//// [index.d.mts] +declare const x: () => T; +export { x }; +//// [index.d.cts] +declare const x: () => T; +export { x }; +//// [index.d.mts] +declare const x: () => T; +export { x }; +//// [index.d.cts] +declare const x: () => T; +export { x }; +//// [index.d.ts] +declare const x: () => T; +export { x }; diff --git a/tests/baselines/reference/nodeModulesForbidenSyntax(module=nodenext).symbols b/tests/baselines/reference/nodeModulesForbidenSyntax(module=nodenext).symbols new file mode 100644 index 0000000000000..1ca35d0d3e32e --- /dev/null +++ b/tests/baselines/reference/nodeModulesForbidenSyntax(module=nodenext).symbols @@ -0,0 +1,120 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +const x = () => (void 0); +>x : Symbol(x, Decl(index.ts, 1, 5)) +>T : Symbol(T, Decl(index.ts, 1, 11)) +>T : Symbol(T, Decl(index.ts, 1, 11)) + +export {x}; +>x : Symbol(x, Decl(index.ts, 2, 8)) + +=== tests/cases/conformance/node/subfolder/index.cts === +// cjs format file +const x = () => (void 0); +>x : Symbol(x, Decl(index.cts, 1, 5)) +>T : Symbol(T, Decl(index.cts, 1, 11)) +>T : Symbol(T, Decl(index.cts, 1, 11)) + +export {x}; +>x : Symbol(x, Decl(index.cts, 2, 8)) + +=== tests/cases/conformance/node/subfolder/index.mts === +// esm format file +const x = () => (void 0); +>x : Symbol(x, Decl(index.mts, 1, 5)) +>T : Symbol(T, Decl(index.mts, 1, 11)) +>T : Symbol(T, Decl(index.mts, 1, 11)) + +export {x}; +>x : Symbol(x, Decl(index.mts, 2, 8)) + +=== tests/cases/conformance/node/subfolder2/index.ts === +// cjs format file +const x = () => (void 0); +>x : Symbol(x, Decl(index.ts, 1, 5)) +>T : Symbol(T, Decl(index.ts, 1, 11)) +>T : Symbol(T, Decl(index.ts, 1, 11)) + +export {x}; +>x : Symbol(x, Decl(index.ts, 2, 8)) + +=== tests/cases/conformance/node/subfolder2/index.cts === +// cjs format file +const x = () => (void 0); +>x : Symbol(x, Decl(index.cts, 1, 5)) +>T : Symbol(T, Decl(index.cts, 1, 11)) +>T : Symbol(T, Decl(index.cts, 1, 11)) + +export {x}; +>x : Symbol(x, Decl(index.cts, 2, 8)) + +=== tests/cases/conformance/node/subfolder2/index.mts === +// esm format file +const x = () => (void 0); +>x : Symbol(x, Decl(index.mts, 1, 5)) +>T : Symbol(T, Decl(index.mts, 1, 11)) +>T : Symbol(T, Decl(index.mts, 1, 11)) + +export {x}; +>x : Symbol(x, Decl(index.mts, 2, 8)) + +=== tests/cases/conformance/node/subfolder2/another/index.ts === +// esm format file +const x = () => (void 0); +>x : Symbol(x, Decl(index.ts, 1, 5)) +>T : Symbol(T, Decl(index.ts, 1, 11)) +>T : Symbol(T, Decl(index.ts, 1, 11)) + +export {x}; +>x : Symbol(x, Decl(index.ts, 2, 8)) + +=== tests/cases/conformance/node/subfolder2/another/index.mts === +// esm format file +const x = () => (void 0); +>x : Symbol(x, Decl(index.mts, 1, 5)) +>T : Symbol(T, Decl(index.mts, 1, 11)) +>T : Symbol(T, Decl(index.mts, 1, 11)) + +export {x}; +>x : Symbol(x, Decl(index.mts, 2, 8)) + +=== tests/cases/conformance/node/subfolder2/another/index.cts === +// cjs format file +const x = () => (void 0); +>x : Symbol(x, Decl(index.cts, 1, 5)) +>T : Symbol(T, Decl(index.cts, 1, 11)) +>T : Symbol(T, Decl(index.cts, 1, 11)) + +export {x}; +>x : Symbol(x, Decl(index.cts, 2, 8)) + +=== tests/cases/conformance/node/index.mts === +// esm format file +const x = () => (void 0); +>x : Symbol(x, Decl(index.mts, 1, 5)) +>T : Symbol(T, Decl(index.mts, 1, 11)) +>T : Symbol(T, Decl(index.mts, 1, 11)) + +export {x}; +>x : Symbol(x, Decl(index.mts, 2, 8)) + +=== tests/cases/conformance/node/index.cts === +// cjs format file +const x = () => (void 0); +>x : Symbol(x, Decl(index.cts, 1, 5)) +>T : Symbol(T, Decl(index.cts, 1, 11)) +>T : Symbol(T, Decl(index.cts, 1, 11)) + +export {x}; +>x : Symbol(x, Decl(index.cts, 2, 8)) + +=== tests/cases/conformance/node/index.ts === +// esm format file +const x = () => (void 0); +>x : Symbol(x, Decl(index.ts, 1, 5)) +>T : Symbol(T, Decl(index.ts, 1, 11)) +>T : Symbol(T, Decl(index.ts, 1, 11)) + +export {x}; +>x : Symbol(x, Decl(index.ts, 2, 8)) + diff --git a/tests/baselines/reference/nodeModulesForbidenSyntax(module=nodenext).types b/tests/baselines/reference/nodeModulesForbidenSyntax(module=nodenext).types new file mode 100644 index 0000000000000..016af4314d16b --- /dev/null +++ b/tests/baselines/reference/nodeModulesForbidenSyntax(module=nodenext).types @@ -0,0 +1,168 @@ +=== tests/cases/conformance/node/subfolder/index.ts === +// cjs format file +const x = () => (void 0); +>x : () => T +>() => (void 0) : () => T +>(void 0) : T +>(void 0) : any +>(void 0) : undefined +>void 0 : undefined +>0 : 0 + +export {x}; +>x : () => T + +=== tests/cases/conformance/node/subfolder/index.cts === +// cjs format file +const x = () => (void 0); +>x : () => T +>() => (void 0) : () => T +>(void 0) : T +>(void 0) : any +>(void 0) : undefined +>void 0 : undefined +>0 : 0 + +export {x}; +>x : () => T + +=== tests/cases/conformance/node/subfolder/index.mts === +// esm format file +const x = () => (void 0); +>x : () => T +>() => (void 0) : () => T +>(void 0) : T +>(void 0) : any +>(void 0) : undefined +>void 0 : undefined +>0 : 0 + +export {x}; +>x : () => T + +=== tests/cases/conformance/node/subfolder2/index.ts === +// cjs format file +const x = () => (void 0); +>x : () => T +>() => (void 0) : () => T +>(void 0) : T +>(void 0) : any +>(void 0) : undefined +>void 0 : undefined +>0 : 0 + +export {x}; +>x : () => T + +=== tests/cases/conformance/node/subfolder2/index.cts === +// cjs format file +const x = () => (void 0); +>x : () => T +>() => (void 0) : () => T +>(void 0) : T +>(void 0) : any +>(void 0) : undefined +>void 0 : undefined +>0 : 0 + +export {x}; +>x : () => T + +=== tests/cases/conformance/node/subfolder2/index.mts === +// esm format file +const x = () => (void 0); +>x : () => T +>() => (void 0) : () => T +>(void 0) : T +>(void 0) : any +>(void 0) : undefined +>void 0 : undefined +>0 : 0 + +export {x}; +>x : () => T + +=== tests/cases/conformance/node/subfolder2/another/index.ts === +// esm format file +const x = () => (void 0); +>x : () => T +>() => (void 0) : () => T +>(void 0) : T +>(void 0) : any +>(void 0) : undefined +>void 0 : undefined +>0 : 0 + +export {x}; +>x : () => T + +=== tests/cases/conformance/node/subfolder2/another/index.mts === +// esm format file +const x = () => (void 0); +>x : () => T +>() => (void 0) : () => T +>(void 0) : T +>(void 0) : any +>(void 0) : undefined +>void 0 : undefined +>0 : 0 + +export {x}; +>x : () => T + +=== tests/cases/conformance/node/subfolder2/another/index.cts === +// cjs format file +const x = () => (void 0); +>x : () => T +>() => (void 0) : () => T +>(void 0) : T +>(void 0) : any +>(void 0) : undefined +>void 0 : undefined +>0 : 0 + +export {x}; +>x : () => T + +=== tests/cases/conformance/node/index.mts === +// esm format file +const x = () => (void 0); +>x : () => T +>() => (void 0) : () => T +>(void 0) : T +>(void 0) : any +>(void 0) : undefined +>void 0 : undefined +>0 : 0 + +export {x}; +>x : () => T + +=== tests/cases/conformance/node/index.cts === +// cjs format file +const x = () => (void 0); +>x : () => T +>() => (void 0) : () => T +>(void 0) : T +>(void 0) : any +>(void 0) : undefined +>void 0 : undefined +>0 : 0 + +export {x}; +>x : () => T + +=== tests/cases/conformance/node/index.ts === +// esm format file +const x = () => (void 0); +>x : () => T +>() => (void 0) : () => T +>(void 0) : T +>(void 0) : any +>(void 0) : undefined +>void 0 : undefined +>0 : 0 + +export {x}; +>x : () => T + diff --git a/tests/baselines/reference/project/invalidRootFile/amd/invalidRootFile.errors.txt b/tests/baselines/reference/project/invalidRootFile/amd/invalidRootFile.errors.txt index 071a8c6b528bc..ce9c2a81f90ee 100644 --- a/tests/baselines/reference/project/invalidRootFile/amd/invalidRootFile.errors.txt +++ b/tests/baselines/reference/project/invalidRootFile/amd/invalidRootFile.errors.txt @@ -1,10 +1,10 @@ error TS6053: File 'a.ts' not found. The file is in the program because: Root file specified for compilation -error TS6054: File 'a.t' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts'. +error TS6054: File 'a.t' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts', '.cts', '.d.cts', '.mts', '.d.mts'. The file is in the program because: Root file specified for compilation -error TS6231: Could not resolve the path 'a' with the extensions: '.ts', '.tsx', '.d.ts'. +error TS6231: Could not resolve the path 'a' with the extensions: '.ts', '.tsx', '.d.ts', '.cts', '.d.cts', '.mts', '.d.mts'. The file is in the program because: Root file specified for compilation @@ -12,9 +12,9 @@ error TS6231: Could not resolve the path 'a' with the extensions: '.ts', '.tsx', !!! error TS6053: File 'a.ts' not found. !!! error TS6053: The file is in the program because: !!! error TS6053: Root file specified for compilation -!!! error TS6054: File 'a.t' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts'. +!!! error TS6054: File 'a.t' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts', '.cts', '.d.cts', '.mts', '.d.mts'. !!! error TS6054: The file is in the program because: !!! error TS6054: Root file specified for compilation -!!! error TS6231: Could not resolve the path 'a' with the extensions: '.ts', '.tsx', '.d.ts'. +!!! error TS6231: Could not resolve the path 'a' with the extensions: '.ts', '.tsx', '.d.ts', '.cts', '.d.cts', '.mts', '.d.mts'. !!! error TS6231: The file is in the program because: !!! error TS6231: Root file specified for compilation \ No newline at end of file diff --git a/tests/baselines/reference/project/invalidRootFile/node/invalidRootFile.errors.txt b/tests/baselines/reference/project/invalidRootFile/node/invalidRootFile.errors.txt index 071a8c6b528bc..ce9c2a81f90ee 100644 --- a/tests/baselines/reference/project/invalidRootFile/node/invalidRootFile.errors.txt +++ b/tests/baselines/reference/project/invalidRootFile/node/invalidRootFile.errors.txt @@ -1,10 +1,10 @@ error TS6053: File 'a.ts' not found. The file is in the program because: Root file specified for compilation -error TS6054: File 'a.t' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts'. +error TS6054: File 'a.t' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts', '.cts', '.d.cts', '.mts', '.d.mts'. The file is in the program because: Root file specified for compilation -error TS6231: Could not resolve the path 'a' with the extensions: '.ts', '.tsx', '.d.ts'. +error TS6231: Could not resolve the path 'a' with the extensions: '.ts', '.tsx', '.d.ts', '.cts', '.d.cts', '.mts', '.d.mts'. The file is in the program because: Root file specified for compilation @@ -12,9 +12,9 @@ error TS6231: Could not resolve the path 'a' with the extensions: '.ts', '.tsx', !!! error TS6053: File 'a.ts' not found. !!! error TS6053: The file is in the program because: !!! error TS6053: Root file specified for compilation -!!! error TS6054: File 'a.t' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts'. +!!! error TS6054: File 'a.t' has an unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts', '.cts', '.d.cts', '.mts', '.d.mts'. !!! error TS6054: The file is in the program because: !!! error TS6054: Root file specified for compilation -!!! error TS6231: Could not resolve the path 'a' with the extensions: '.ts', '.tsx', '.d.ts'. +!!! error TS6231: Could not resolve the path 'a' with the extensions: '.ts', '.tsx', '.d.ts', '.cts', '.d.cts', '.mts', '.d.mts'. !!! error TS6231: The file is in the program because: !!! error TS6231: Root file specified for compilation \ No newline at end of file diff --git a/tests/baselines/reference/tsbuild/watchMode/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-cts-and-mts-extensions.js b/tests/baselines/reference/tsbuild/watchMode/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-cts-and-mts-extensions.js new file mode 100644 index 0000000000000..03cd75fe0268e --- /dev/null +++ b/tests/baselines/reference/tsbuild/watchMode/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-cts-and-mts-extensions.js @@ -0,0 +1,485 @@ +Input:: +//// [/user/username/projects/myproject/packages/pkg1/package.json] +{"name":"pkg1","version":"1.0.0","main":"build/index.js","type":"module"} + +//// [/user/username/projects/myproject/packages/pkg1/index.ts] +import type { TheNum } from 'pkg2' +export const theNum: TheNum = 42; + +//// [/user/username/projects/myproject/packages/pkg1/tsconfig.json] +{"compilerOptions":{"outDir":"build","module":"node12"},"references":[{"path":"../pkg2"}]} + +//// [/user/username/projects/myproject/packages/pkg2/const.cts] +export type TheNum = 42; + +//// [/user/username/projects/myproject/packages/pkg2/index.ts] +export type { TheNum } from './const.cjs'; + +//// [/user/username/projects/myproject/packages/pkg2/tsconfig.json] +{"compilerOptions":{"composite":true,"outDir":"build","module":"node12"}} + +//// [/user/username/projects/myproject/packages/pkg2/package.json] +{"name":"pkg2","version":"1.0.0","main":"build/index.js","type":"module"} + +//// [/user/username/projects/myproject/node_modules/pkg2] symlink(/user/username/projects/myproject/packages/pkg2) +//// [/a/lib/lib.es2020.full.d.ts] +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } + + +/a/lib/tsc.js -b packages/pkg1 -w --verbose --traceResolution +Output:: +>> Screen clear +[12:00:41 AM] Starting compilation in watch mode... + +[12:00:42 AM] Projects in this build: + * packages/pkg2/tsconfig.json + * packages/pkg1/tsconfig.json + +[12:00:43 AM] Project 'packages/pkg2/tsconfig.json' is out of date because output file 'packages/pkg2/build/const.cjs' does not exist + +[12:00:44 AM] Building project '/user/username/projects/myproject/packages/pkg2/tsconfig.json'... + +Found 'package.json' at '/user/username/projects/myproject/packages/pkg2/package.json'. +'package.json' does not have a 'typesVersions' field. +======== Resolving module './const.cjs' from '/user/username/projects/myproject/packages/pkg2/index.ts'. ======== +Module resolution kind is not specified, using 'Node12'. +Loading module as file / folder, candidate module location '/user/username/projects/myproject/packages/pkg2/const.cjs', target file type 'TypeScript'. +File '/user/username/projects/myproject/packages/pkg2/const.cjs.ts' does not exist. +File '/user/username/projects/myproject/packages/pkg2/const.cjs.tsx' does not exist. +File '/user/username/projects/myproject/packages/pkg2/const.cjs.d.ts' does not exist. +File name '/user/username/projects/myproject/packages/pkg2/const.cjs' has a '.cjs' extension - stripping it. +File '/user/username/projects/myproject/packages/pkg2/const.cts' exist - use it as a name resolution result. +======== Module name './const.cjs' was successfully resolved to '/user/username/projects/myproject/packages/pkg2/const.cts'. ======== +File '/a/lib/package.json' does not exist. +File '/a/package.json' does not exist. +File '/package.json' does not exist. +[12:01:00 AM] Project 'packages/pkg1/tsconfig.json' is out of date because output file 'packages/pkg1/build/index.js' does not exist + +[12:01:01 AM] Building project '/user/username/projects/myproject/packages/pkg1/tsconfig.json'... + +Found 'package.json' at '/user/username/projects/myproject/packages/pkg1/package.json'. +'package.json' does not have a 'typesVersions' field. +======== Resolving module 'pkg2' from '/user/username/projects/myproject/packages/pkg1/index.ts'. ======== +Module resolution kind is not specified, using 'Node12'. +Loading module 'pkg2' from 'node_modules' folder, target file type 'TypeScript'. +Directory '/user/username/projects/myproject/packages/pkg1/node_modules' does not exist, skipping all lookups in it. +Directory '/user/username/projects/myproject/packages/node_modules' does not exist, skipping all lookups in it. +Found 'package.json' at '/user/username/projects/myproject/node_modules/pkg2/package.json'. +'package.json' does not have a 'typesVersions' field. +File '/user/username/projects/myproject/node_modules/pkg2.ts' does not exist. +File '/user/username/projects/myproject/node_modules/pkg2.tsx' does not exist. +File '/user/username/projects/myproject/node_modules/pkg2.d.ts' does not exist. +'package.json' does not have a 'typings' field. +'package.json' does not have a 'types' field. +'package.json' has 'main' field 'build/index.js' that references '/user/username/projects/myproject/node_modules/pkg2/build/index.js'. +File '/user/username/projects/myproject/node_modules/pkg2/build/index.js' exist - use it as a name resolution result. +File '/user/username/projects/myproject/node_modules/pkg2/build/index.js' has an unsupported extension, so skipping it. +Loading module as file / folder, candidate module location '/user/username/projects/myproject/node_modules/pkg2/build/index.js', target file type 'TypeScript'. +File '/user/username/projects/myproject/node_modules/pkg2/build/index.js.ts' does not exist. +File '/user/username/projects/myproject/node_modules/pkg2/build/index.js.tsx' does not exist. +File '/user/username/projects/myproject/node_modules/pkg2/build/index.js.d.ts' does not exist. +File name '/user/username/projects/myproject/node_modules/pkg2/build/index.js' has a '.js' extension - stripping it. +File '/user/username/projects/myproject/node_modules/pkg2/build/index.ts' does not exist. +File '/user/username/projects/myproject/node_modules/pkg2/build/index.tsx' does not exist. +File '/user/username/projects/myproject/node_modules/pkg2/build/index.d.ts' exist - use it as a name resolution result. +Resolving real path for '/user/username/projects/myproject/node_modules/pkg2/build/index.d.ts', result '/user/username/projects/myproject/packages/pkg2/build/index.d.ts'. +======== Module name 'pkg2' was successfully resolved to '/user/username/projects/myproject/packages/pkg2/build/index.d.ts' with Package ID 'pkg2/build/index.d.ts@1.0.0'. ======== +File '/user/username/projects/myproject/packages/pkg2/build/package.json' does not exist. +Found 'package.json' at '/user/username/projects/myproject/packages/pkg2/package.json'. +'package.json' does not have a 'typesVersions' field. +======== Resolving module './const.cjs' from '/user/username/projects/myproject/packages/pkg2/build/index.d.ts'. ======== +Using compiler options of project reference redirect '/user/username/projects/myproject/packages/pkg2/tsconfig.json'. +Module resolution kind is not specified, using 'Node12'. +Loading module as file / folder, candidate module location '/user/username/projects/myproject/packages/pkg2/build/const.cjs', target file type 'TypeScript'. +File '/user/username/projects/myproject/packages/pkg2/build/const.cjs.ts' does not exist. +File '/user/username/projects/myproject/packages/pkg2/build/const.cjs.tsx' does not exist. +File '/user/username/projects/myproject/packages/pkg2/build/const.cjs.d.ts' does not exist. +File name '/user/username/projects/myproject/packages/pkg2/build/const.cjs' has a '.cjs' extension - stripping it. +File '/user/username/projects/myproject/packages/pkg2/build/const.cts' does not exist. +File '/user/username/projects/myproject/packages/pkg2/build/const.d.cts' exist - use it as a name resolution result. +======== Module name './const.cjs' was successfully resolved to '/user/username/projects/myproject/packages/pkg2/build/const.d.cts'. ======== +File '/a/lib/package.json' does not exist. +File '/a/package.json' does not exist. +File '/package.json' does not exist. +[12:01:07 AM] Found 0 errors. Watching for file changes. + + + +Program root files: ["/user/username/projects/myproject/packages/pkg2/const.cts","/user/username/projects/myproject/packages/pkg2/index.ts"] +Program options: {"composite":true,"outDir":"/user/username/projects/myproject/packages/pkg2/build","module":100,"watch":true,"traceResolution":true,"configFilePath":"/user/username/projects/myproject/packages/pkg2/tsconfig.json"} +Program structureReused: Not +Program files:: +/a/lib/lib.es2020.full.d.ts +/user/username/projects/myproject/packages/pkg2/const.cts +/user/username/projects/myproject/packages/pkg2/index.ts + +Semantic diagnostics in builder refreshed for:: +/a/lib/lib.es2020.full.d.ts +/user/username/projects/myproject/packages/pkg2/const.cts +/user/username/projects/myproject/packages/pkg2/index.ts + +Shape signatures in builder refreshed for:: +/a/lib/lib.es2020.full.d.ts (used version) +/user/username/projects/myproject/packages/pkg2/const.cts (used version) +/user/username/projects/myproject/packages/pkg2/index.ts (used version) + +Program root files: ["/user/username/projects/myproject/packages/pkg1/index.ts"] +Program options: {"outDir":"/user/username/projects/myproject/packages/pkg1/build","module":100,"watch":true,"traceResolution":true,"configFilePath":"/user/username/projects/myproject/packages/pkg1/tsconfig.json"} +Program structureReused: Not +Program files:: +/a/lib/lib.es2020.full.d.ts +/user/username/projects/myproject/packages/pkg2/build/index.d.ts +/user/username/projects/myproject/packages/pkg1/index.ts + +Semantic diagnostics in builder refreshed for:: +/a/lib/lib.es2020.full.d.ts +/user/username/projects/myproject/packages/pkg2/build/index.d.ts +/user/username/projects/myproject/packages/pkg1/index.ts + +Shape signatures in builder refreshed for:: +/a/lib/lib.es2020.full.d.ts (used version) +/user/username/projects/myproject/packages/pkg2/build/index.d.ts (used version) +/user/username/projects/myproject/packages/pkg1/index.ts (used version) + +WatchedFiles:: +/user/username/projects/myproject/packages/pkg2/tsconfig.json: + {"fileName":"/user/username/projects/myproject/packages/pkg2/tsconfig.json","pollingInterval":250} +/user/username/projects/myproject/packages/pkg2/const.cts: + {"fileName":"/user/username/projects/myproject/packages/pkg2/const.cts","pollingInterval":250} +/user/username/projects/myproject/packages/pkg2/index.ts: + {"fileName":"/user/username/projects/myproject/packages/pkg2/index.ts","pollingInterval":250} +/user/username/projects/myproject/packages/pkg1/tsconfig.json: + {"fileName":"/user/username/projects/myproject/packages/pkg1/tsconfig.json","pollingInterval":250} +/user/username/projects/myproject/packages/pkg1/index.ts: + {"fileName":"/user/username/projects/myproject/packages/pkg1/index.ts","pollingInterval":250} + +FsWatches:: + +FsWatchesRecursive:: +/user/username/projects/myproject/packages/pkg2: + {"directoryName":"/user/username/projects/myproject/packages/pkg2","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}} +/user/username/projects/myproject/packages/pkg1: + {"directoryName":"/user/username/projects/myproject/packages/pkg1","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}} + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/packages/pkg2/build/const.cjs] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); + + +//// [/user/username/projects/myproject/packages/pkg2/build/const.d.cts] +export declare type TheNum = 42; + + +//// [/user/username/projects/myproject/packages/pkg2/build/index.js] +export {}; + + +//// [/user/username/projects/myproject/packages/pkg2/build/index.d.ts] +export type { TheNum } from './const.cjs'; + + +//// [/user/username/projects/myproject/packages/pkg2/build/tsconfig.tsbuildinfo] +{"program":{"fileNames":["../../../../../../../a/lib/lib.es2020.full.d.ts","../const.cts","../index.ts"],"fileInfos":[{"version":"-7698705165-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }","affectsGlobalScope":true},"-11202312776-export type TheNum = 42;","-9668872159-export type { TheNum } from './const.cjs';"],"options":{"composite":true,"module":100,"outDir":"./"},"fileIdsList":[[2]],"referencedMap":[[3,1]],"exportedModulesMap":[[3,1]],"semanticDiagnosticsPerFile":[1,2,3]},"version":"FakeTSVersion"} + +//// [/user/username/projects/myproject/packages/pkg2/build/tsconfig.tsbuildinfo.readable.baseline.txt] +{ + "program": { + "fileNames": [ + "../../../../../../../a/lib/lib.es2020.full.d.ts", + "../const.cts", + "../index.ts" + ], + "fileNamesList": [ + [ + "../const.cts" + ] + ], + "fileInfos": { + "../../../../../../../a/lib/lib.es2020.full.d.ts": { + "version": "-7698705165-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }", + "signature": "-7698705165-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }", + "affectsGlobalScope": true + }, + "../const.cts": { + "version": "-11202312776-export type TheNum = 42;", + "signature": "-11202312776-export type TheNum = 42;" + }, + "../index.ts": { + "version": "-9668872159-export type { TheNum } from './const.cjs';", + "signature": "-9668872159-export type { TheNum } from './const.cjs';" + } + }, + "options": { + "composite": true, + "module": 100, + "outDir": "./" + }, + "referencedMap": { + "../index.ts": [ + "../const.cts" + ] + }, + "exportedModulesMap": { + "../index.ts": [ + "../const.cts" + ] + }, + "semanticDiagnosticsPerFile": [ + "../../../../../../../a/lib/lib.es2020.full.d.ts", + "../const.cts", + "../index.ts" + ] + }, + "version": "FakeTSVersion", + "size": 808 +} + +//// [/user/username/projects/myproject/packages/pkg1/build/index.js] +export const theNum = 42; + + + +Change:: reports import errors after change to package file + +Input:: +//// [/user/username/projects/myproject/packages/pkg1/package.json] +{"name":"pkg1","version":"1.0.0","main":"build/index.js","type":"commonjs"} + + +Output:: + +WatchedFiles:: +/user/username/projects/myproject/packages/pkg2/tsconfig.json: + {"fileName":"/user/username/projects/myproject/packages/pkg2/tsconfig.json","pollingInterval":250} +/user/username/projects/myproject/packages/pkg2/const.cts: + {"fileName":"/user/username/projects/myproject/packages/pkg2/const.cts","pollingInterval":250} +/user/username/projects/myproject/packages/pkg2/index.ts: + {"fileName":"/user/username/projects/myproject/packages/pkg2/index.ts","pollingInterval":250} +/user/username/projects/myproject/packages/pkg1/tsconfig.json: + {"fileName":"/user/username/projects/myproject/packages/pkg1/tsconfig.json","pollingInterval":250} +/user/username/projects/myproject/packages/pkg1/index.ts: + {"fileName":"/user/username/projects/myproject/packages/pkg1/index.ts","pollingInterval":250} + +FsWatches:: + +FsWatchesRecursive:: +/user/username/projects/myproject/packages/pkg2: + {"directoryName":"/user/username/projects/myproject/packages/pkg2","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}} +/user/username/projects/myproject/packages/pkg1: + {"directoryName":"/user/username/projects/myproject/packages/pkg1","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}} + +exitCode:: ExitStatus.undefined + + +Change:: removes those errors when a package file is changed back + +Input:: +//// [/user/username/projects/myproject/packages/pkg1/package.json] +{"name":"pkg1","version":"1.0.0","main":"build/index.js","type":"module"} + + +Output:: + +WatchedFiles:: +/user/username/projects/myproject/packages/pkg2/tsconfig.json: + {"fileName":"/user/username/projects/myproject/packages/pkg2/tsconfig.json","pollingInterval":250} +/user/username/projects/myproject/packages/pkg2/const.cts: + {"fileName":"/user/username/projects/myproject/packages/pkg2/const.cts","pollingInterval":250} +/user/username/projects/myproject/packages/pkg2/index.ts: + {"fileName":"/user/username/projects/myproject/packages/pkg2/index.ts","pollingInterval":250} +/user/username/projects/myproject/packages/pkg1/tsconfig.json: + {"fileName":"/user/username/projects/myproject/packages/pkg1/tsconfig.json","pollingInterval":250} +/user/username/projects/myproject/packages/pkg1/index.ts: + {"fileName":"/user/username/projects/myproject/packages/pkg1/index.ts","pollingInterval":250} + +FsWatches:: + +FsWatchesRecursive:: +/user/username/projects/myproject/packages/pkg2: + {"directoryName":"/user/username/projects/myproject/packages/pkg2","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}} +/user/username/projects/myproject/packages/pkg1: + {"directoryName":"/user/username/projects/myproject/packages/pkg1","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}} + +exitCode:: ExitStatus.undefined + + +Change:: reports import errors after change to package file + +Input:: +//// [/user/username/projects/myproject/packages/pkg1/package.json] +{"name":"pkg1","version":"1.0.0","main":"build/index.js","type":"commonjs"} + + +Output:: + +WatchedFiles:: +/user/username/projects/myproject/packages/pkg2/tsconfig.json: + {"fileName":"/user/username/projects/myproject/packages/pkg2/tsconfig.json","pollingInterval":250} +/user/username/projects/myproject/packages/pkg2/const.cts: + {"fileName":"/user/username/projects/myproject/packages/pkg2/const.cts","pollingInterval":250} +/user/username/projects/myproject/packages/pkg2/index.ts: + {"fileName":"/user/username/projects/myproject/packages/pkg2/index.ts","pollingInterval":250} +/user/username/projects/myproject/packages/pkg1/tsconfig.json: + {"fileName":"/user/username/projects/myproject/packages/pkg1/tsconfig.json","pollingInterval":250} +/user/username/projects/myproject/packages/pkg1/index.ts: + {"fileName":"/user/username/projects/myproject/packages/pkg1/index.ts","pollingInterval":250} + +FsWatches:: + +FsWatchesRecursive:: +/user/username/projects/myproject/packages/pkg2: + {"directoryName":"/user/username/projects/myproject/packages/pkg2","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}} +/user/username/projects/myproject/packages/pkg1: + {"directoryName":"/user/username/projects/myproject/packages/pkg1","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}} + +exitCode:: ExitStatus.undefined + + +Change:: removes those errors when a package file is changed to cjs extensions + +Input:: +//// [/user/username/projects/myproject/packages/pkg2/package.json] file written with same contents +//// [/user/username/projects/myproject/packages/pkg2/index.cts] +export type { TheNum } from './const.cjs'; + +//// [/user/username/projects/myproject/packages/pkg2/index.ts] deleted + +Output:: +>> Screen clear +[12:01:23 AM] File change detected. Starting incremental compilation... + +[12:01:24 AM] Project 'packages/pkg2/tsconfig.json' is out of date because oldest output 'packages/pkg2/build/const.cjs' is older than newest input 'packages/pkg2/index.cts' + +[12:01:25 AM] Building project '/user/username/projects/myproject/packages/pkg2/tsconfig.json'... + +======== Resolving module './const.cjs' from '/user/username/projects/myproject/packages/pkg2/index.cts'. ======== +Module resolution kind is not specified, using 'Node12'. +Loading module as file / folder, candidate module location '/user/username/projects/myproject/packages/pkg2/const.cjs', target file type 'TypeScript'. +File '/user/username/projects/myproject/packages/pkg2/const.cjs.ts' does not exist. +File '/user/username/projects/myproject/packages/pkg2/const.cjs.tsx' does not exist. +File '/user/username/projects/myproject/packages/pkg2/const.cjs.d.ts' does not exist. +File name '/user/username/projects/myproject/packages/pkg2/const.cjs' has a '.cjs' extension - stripping it. +File '/user/username/projects/myproject/packages/pkg2/const.cts' exist - use it as a name resolution result. +======== Module name './const.cjs' was successfully resolved to '/user/username/projects/myproject/packages/pkg2/const.cts'. ======== +File '/a/lib/package.json' does not exist. +File '/a/package.json' does not exist. +File '/package.json' does not exist. +[12:01:34 AM] Updating unchanged output timestamps of project '/user/username/projects/myproject/packages/pkg2/tsconfig.json'... + + + +Program root files: ["/user/username/projects/myproject/packages/pkg2/const.cts","/user/username/projects/myproject/packages/pkg2/index.cts"] +Program options: {"composite":true,"outDir":"/user/username/projects/myproject/packages/pkg2/build","module":100,"watch":true,"traceResolution":true,"configFilePath":"/user/username/projects/myproject/packages/pkg2/tsconfig.json"} +Program structureReused: Not +Program files:: +/a/lib/lib.es2020.full.d.ts +/user/username/projects/myproject/packages/pkg2/const.cts +/user/username/projects/myproject/packages/pkg2/index.cts + +Semantic diagnostics in builder refreshed for:: +/user/username/projects/myproject/packages/pkg2/index.cts + +Shape signatures in builder refreshed for:: +/user/username/projects/myproject/packages/pkg2/index.cts (computed .d.ts) + +WatchedFiles:: +/user/username/projects/myproject/packages/pkg2/tsconfig.json: + {"fileName":"/user/username/projects/myproject/packages/pkg2/tsconfig.json","pollingInterval":250} +/user/username/projects/myproject/packages/pkg2/const.cts: + {"fileName":"/user/username/projects/myproject/packages/pkg2/const.cts","pollingInterval":250} +/user/username/projects/myproject/packages/pkg1/tsconfig.json: + {"fileName":"/user/username/projects/myproject/packages/pkg1/tsconfig.json","pollingInterval":250} +/user/username/projects/myproject/packages/pkg1/index.ts: + {"fileName":"/user/username/projects/myproject/packages/pkg1/index.ts","pollingInterval":250} +/user/username/projects/myproject/packages/pkg2/index.cts: + {"fileName":"/user/username/projects/myproject/packages/pkg2/index.cts","pollingInterval":250} + +FsWatches:: + +FsWatchesRecursive:: +/user/username/projects/myproject/packages/pkg2: + {"directoryName":"/user/username/projects/myproject/packages/pkg2","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}} +/user/username/projects/myproject/packages/pkg1: + {"directoryName":"/user/username/projects/myproject/packages/pkg1","fallbackPollingInterval":500,"fallbackOptions":{"watchFile":"PriorityPollingInterval"}} + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/myproject/packages/pkg2/build/const.cjs] file changed its modified time +//// [/user/username/projects/myproject/packages/pkg2/build/const.d.cts] file changed its modified time +//// [/user/username/projects/myproject/packages/pkg2/build/tsconfig.tsbuildinfo] +{"program":{"fileNames":["../../../../../../../a/lib/lib.es2020.full.d.ts","../const.cts","../index.cts"],"fileInfos":[{"version":"-7698705165-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }","affectsGlobalScope":true},"-11202312776-export type TheNum = 42;",{"version":"-9668872159-export type { TheNum } from './const.cjs';","signature":"-9835135925-export type { TheNum } from './const.cjs';\n"}],"options":{"composite":true,"module":100,"outDir":"./"},"fileIdsList":[[2]],"referencedMap":[[3,1]],"exportedModulesMap":[[3,1]],"semanticDiagnosticsPerFile":[1,2,3]},"version":"FakeTSVersion"} + +//// [/user/username/projects/myproject/packages/pkg2/build/tsconfig.tsbuildinfo.readable.baseline.txt] +{ + "program": { + "fileNames": [ + "../../../../../../../a/lib/lib.es2020.full.d.ts", + "../const.cts", + "../index.cts" + ], + "fileNamesList": [ + [ + "../const.cts" + ] + ], + "fileInfos": { + "../../../../../../../a/lib/lib.es2020.full.d.ts": { + "version": "-7698705165-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }", + "signature": "-7698705165-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }", + "affectsGlobalScope": true + }, + "../const.cts": { + "version": "-11202312776-export type TheNum = 42;", + "signature": "-11202312776-export type TheNum = 42;" + }, + "../index.cts": { + "version": "-9668872159-export type { TheNum } from './const.cjs';", + "signature": "-9835135925-export type { TheNum } from './const.cjs';\n" + } + }, + "options": { + "composite": true, + "module": 100, + "outDir": "./" + }, + "referencedMap": { + "../index.cts": [ + "../const.cts" + ] + }, + "exportedModulesMap": { + "../index.cts": [ + "../const.cts" + ] + }, + "semanticDiagnosticsPerFile": [ + "../../../../../../../a/lib/lib.es2020.full.d.ts", + "../const.cts", + "../index.cts" + ] + }, + "version": "FakeTSVersion", + "size": 892 +} + +//// [/user/username/projects/myproject/packages/pkg2/build/index.cjs] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); + + +//// [/user/username/projects/myproject/packages/pkg2/build/index.d.cts] +export type { TheNum } from './const.cjs'; + + diff --git a/tests/cases/conformance/node/allowJs/nodeModulesAllowJs1.ts b/tests/cases/conformance/node/allowJs/nodeModulesAllowJs1.ts index 9b27ee95c1789..174300a96b045 100644 --- a/tests/cases/conformance/node/allowJs/nodeModulesAllowJs1.ts +++ b/tests/cases/conformance/node/allowJs/nodeModulesAllowJs1.ts @@ -7,15 +7,120 @@ // cjs format file const x = 1; export {x}; +// @filename: subfolder/index.cjs +// cjs format file +const x = 1; +export {x}; +// @filename: subfolder/index.mjs +// esm format file +const x = 1; +export {x}; // @filename: subfolder2/index.js // cjs format file const x = 1; export {x}; +// @filename: subfolder2/index.cjs +// cjs format file +const x = 1; +export {x}; +// @filename: subfolder2/index.mjs +// esm format file +const x = 1; +export {x}; // @filename: subfolder2/another/index.js // esm format file const x = 1; export {x}; +// @filename: subfolder2/another/index.cjs +// cjs format file +const x = 1; +export {x}; +// @filename: subfolder2/another/index.mjs +// esm format file +const x = 1; +export {x}; // @filename: index.js +import * as m1 from "./index.js"; +import * as m2 from "./index.mjs"; +import * as m3 from "./index.cjs"; +import * as m4 from "./subfolder/index.js"; +import * as m5 from "./subfolder/index.mjs"; +import * as m6 from "./subfolder/index.cjs"; +import * as m7 from "./subfolder2/index.js"; +import * as m8 from "./subfolder2/index.mjs"; +import * as m9 from "./subfolder2/index.cjs"; +import * as m10 from "./subfolder2/another/index.js"; +import * as m11 from "./subfolder2/another/index.mjs"; +import * as m12 from "./subfolder2/another/index.cjs"; +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; +// esm format file +const x = 1; +export {x}; +// @filename: index.cjs +// ESM format imports below should error +import * as m1 from "./index.js"; +import * as m2 from "./index.mjs"; +import * as m3 from "./index.cjs"; +import * as m4 from "./subfolder/index.js"; +import * as m5 from "./subfolder/index.mjs"; +import * as m6 from "./subfolder/index.cjs"; +import * as m7 from "./subfolder2/index.js"; +import * as m8 from "./subfolder2/index.mjs"; +import * as m9 from "./subfolder2/index.cjs"; +import * as m10 from "./subfolder2/another/index.js"; +import * as m11 from "./subfolder2/another/index.mjs"; +import * as m12 from "./subfolder2/another/index.cjs"; +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; +// cjs format file +const x = 1; +export {x}; +// @filename: index.mjs +import * as m1 from "./index.js"; +import * as m2 from "./index.mjs"; +import * as m3 from "./index.cjs"; +import * as m4 from "./subfolder/index.js"; +import * as m5 from "./subfolder/index.mjs"; +import * as m6 from "./subfolder/index.cjs"; +import * as m7 from "./subfolder2/index.js"; +import * as m8 from "./subfolder2/index.mjs"; +import * as m9 from "./subfolder2/index.cjs"; +import * as m10 from "./subfolder2/another/index.js"; +import * as m11 from "./subfolder2/another/index.mjs"; +import * as m12 from "./subfolder2/another/index.cjs"; +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; // esm format file const x = 1; export {x}; diff --git a/tests/cases/conformance/node/nodeModules1.ts b/tests/cases/conformance/node/nodeModules1.ts index 349d103b0efcf..b0ba13a1e346e 100644 --- a/tests/cases/conformance/node/nodeModules1.ts +++ b/tests/cases/conformance/node/nodeModules1.ts @@ -4,15 +4,120 @@ // cjs format file const x = 1; export {x}; +// @filename: subfolder/index.cts +// cjs format file +const x = 1; +export {x}; +// @filename: subfolder/index.mts +// esm format file +const x = 1; +export {x}; // @filename: subfolder2/index.ts // cjs format file const x = 1; export {x}; +// @filename: subfolder2/index.cts +// cjs format file +const x = 1; +export {x}; +// @filename: subfolder2/index.mts +// esm format file +const x = 1; +export {x}; // @filename: subfolder2/another/index.ts // esm format file const x = 1; export {x}; +// @filename: subfolder2/another/index.mts +// esm format file +const x = 1; +export {x}; +// @filename: subfolder2/another/index.cts +// cjs format file +const x = 1; +export {x}; +// @filename: index.mts +import * as m1 from "./index.js"; +import * as m2 from "./index.mjs"; +import * as m3 from "./index.cjs"; +import * as m4 from "./subfolder/index.js"; +import * as m5 from "./subfolder/index.mjs"; +import * as m6 from "./subfolder/index.cjs"; +import * as m7 from "./subfolder2/index.js"; +import * as m8 from "./subfolder2/index.mjs"; +import * as m9 from "./subfolder2/index.cjs"; +import * as m10 from "./subfolder2/another/index.js"; +import * as m11 from "./subfolder2/another/index.mjs"; +import * as m12 from "./subfolder2/another/index.cjs"; +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; +// esm format file +const x = 1; +export {x}; +// @filename: index.cts +// ESM-format imports below should issue errors +import * as m1 from "./index.js"; +import * as m2 from "./index.mjs"; +import * as m3 from "./index.cjs"; +import * as m4 from "./subfolder/index.js"; +import * as m5 from "./subfolder/index.mjs"; +import * as m6 from "./subfolder/index.cjs"; +import * as m7 from "./subfolder2/index.js"; +import * as m8 from "./subfolder2/index.mjs"; +import * as m9 from "./subfolder2/index.cjs"; +import * as m10 from "./subfolder2/another/index.js"; +import * as m11 from "./subfolder2/another/index.mjs"; +import * as m12 from "./subfolder2/another/index.cjs"; +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; +// cjs format file +const x = 1; +export {x}; // @filename: index.ts +import * as m1 from "./index.js"; +import * as m2 from "./index.mjs"; +import * as m3 from "./index.cjs"; +import * as m4 from "./subfolder/index.js"; +import * as m5 from "./subfolder/index.mjs"; +import * as m6 from "./subfolder/index.cjs"; +import * as m7 from "./subfolder2/index.js"; +import * as m8 from "./subfolder2/index.mjs"; +import * as m9 from "./subfolder2/index.cjs"; +import * as m10 from "./subfolder2/another/index.js"; +import * as m11 from "./subfolder2/another/index.mjs"; +import * as m12 from "./subfolder2/another/index.cjs"; +void m1; +void m2; +void m3; +void m4; +void m5; +void m6; +void m7; +void m8; +void m9; +void m10; +void m11; +void m12; // esm format file const x = 1; export {x}; diff --git a/tests/cases/conformance/node/nodeModulesForbidenSyntax.ts b/tests/cases/conformance/node/nodeModulesForbidenSyntax.ts new file mode 100644 index 0000000000000..d441627d7d0c4 --- /dev/null +++ b/tests/cases/conformance/node/nodeModulesForbidenSyntax.ts @@ -0,0 +1,67 @@ +// @module: node12,nodenext +// @declaration: true +// @filename: subfolder/index.ts +// cjs format file +const x = () => (void 0); +export {x}; +// @filename: subfolder/index.cts +// cjs format file +const x = () => (void 0); +export {x}; +// @filename: subfolder/index.mts +// esm format file +const x = () => (void 0); +export {x}; +// @filename: subfolder2/index.ts +// cjs format file +const x = () => (void 0); +export {x}; +// @filename: subfolder2/index.cts +// cjs format file +const x = () => (void 0); +export {x}; +// @filename: subfolder2/index.mts +// esm format file +const x = () => (void 0); +export {x}; +// @filename: subfolder2/another/index.ts +// esm format file +const x = () => (void 0); +export {x}; +// @filename: subfolder2/another/index.mts +// esm format file +const x = () => (void 0); +export {x}; +// @filename: subfolder2/another/index.cts +// cjs format file +const x = () => (void 0); +export {x}; +// @filename: index.mts +// esm format file +const x = () => (void 0); +export {x}; +// @filename: index.cts +// cjs format file +const x = () => (void 0); +export {x}; +// @filename: index.ts +// esm format file +const x = () => (void 0); +export {x}; +// @filename: package.json +{ + "name": "package", + "private": true, + "type": "module" +} +// @filename: subfolder/package.json +{ + "type": "commonjs" +} +// @filename: subfolder2/package.json +{ +} +// @filename: subfolder2/another/package.json +{ + "type": "module" +} \ No newline at end of file From e6a386c9b4de959af044ce50f8764b2ca6704add Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Thu, 26 Aug 2021 14:41:55 -0700 Subject: [PATCH 5/9] Fix watch of files whose intepretation changes due to a package.json update --- src/compiler/builder.ts | 18 +- src/compiler/builderState.ts | 3 +- src/compiler/program.ts | 1 + src/compiler/tsbuildPublic.ts | 1 + src/compiler/types.ts | 4 + .../unittests/tsbuild/moduleResolution.ts | 4 +- .../unittests/tscWatch/incremental.ts | 3 + .../reference/api/tsserverlibrary.d.ts | 4 + tests/baselines/reference/api/typescript.d.ts | 4 + ...t-correctly-with-cts-and-mts-extensions.js | 343 ++++++++++++++++-- 10 files changed, 350 insertions(+), 35 deletions(-) diff --git a/src/compiler/builder.ts b/src/compiler/builder.ts index 2b578cecfc035..aec8cae3cea12 100644 --- a/src/compiler/builder.ts +++ b/src/compiler/builder.ts @@ -258,6 +258,14 @@ namespace ts { Debug.assert(!state.seenAffectedFiles || !state.seenAffectedFiles.size); state.seenAffectedFiles = state.seenAffectedFiles || new Set(); } + if (useOldState) { + // Any time the interpretation of a source file changes, mark it as changed + forEachEntry(oldState!.fileInfos, (info, sourceFilePath) => { + if (state.fileInfos.has(sourceFilePath) && state.fileInfos.get(sourceFilePath)!.impliedFormat !== info.impliedFormat) { + state.changedFilesSet.add(sourceFilePath); + } + }); + } state.buildInfoEmitPending = !!state.changedFilesSet.size; return state; @@ -744,13 +752,13 @@ namespace ts { const actualSignature = signature ?? value.signature; return value.version === actualSignature ? value.affectsGlobalScope ? - { version: value.version, signature: undefined, affectsGlobalScope: true } : + { version: value.version, signature: undefined, affectsGlobalScope: true, impliedFormat: value.impliedFormat } : value.version : actualSignature !== undefined ? signature === undefined ? value : - { version: value.version, signature, affectsGlobalScope: value.affectsGlobalScope } : - { version: value.version, signature: false, affectsGlobalScope: value.affectsGlobalScope }; + { version: value.version, signature, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } : + { version: value.version, signature: false, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat }; }); let referencedMap: ProgramBuildInfoReferencedMap | undefined; @@ -1243,10 +1251,10 @@ namespace ts { export function toBuilderStateFileInfo(fileInfo: ProgramBuildInfoFileInfo): BuilderState.FileInfo { return isString(fileInfo) ? - { version: fileInfo, signature: fileInfo, affectsGlobalScope: undefined } : + { version: fileInfo, signature: fileInfo, affectsGlobalScope: undefined, impliedFormat: undefined } : isString(fileInfo.signature) ? fileInfo as BuilderState.FileInfo : - { version: fileInfo.version, signature: fileInfo.signature === false ? undefined : fileInfo.version, affectsGlobalScope: fileInfo.affectsGlobalScope }; + { version: fileInfo.version, signature: fileInfo.signature === false ? undefined : fileInfo.version, affectsGlobalScope: fileInfo.affectsGlobalScope, impliedFormat: fileInfo.impliedFormat }; } export function createBuildProgramUsingProgramBuildInfo(program: ProgramBuildInfo, buildInfoPath: string, host: ReadBuildProgramHost): EmitAndSemanticDiagnosticsBuilderProgram { diff --git a/src/compiler/builderState.ts b/src/compiler/builderState.ts index f48d52c3e9d6b..a64a6c13ed1e8 100644 --- a/src/compiler/builderState.ts +++ b/src/compiler/builderState.ts @@ -82,6 +82,7 @@ namespace ts { readonly version: string; signature: string | undefined; affectsGlobalScope: boolean | undefined; + impliedFormat: number | undefined; } export interface ReadonlyManyToManyPathMap { @@ -332,7 +333,7 @@ namespace ts { } } } - fileInfos.set(sourceFile.resolvedPath, { version, signature: oldInfo && oldInfo.signature, affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) || undefined }); + fileInfos.set(sourceFile.resolvedPath, { version, signature: oldInfo && oldInfo.signature, affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) || undefined, impliedFormat: sourceFile.impliedNodeFormat }); } return { diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 932fdebe43607..e446b32df7626 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -903,6 +903,7 @@ namespace ts { withExtension.extension = extensionFromPath(resolved.resolvedFileName); return withExtension; }); + moduleResolutionCache = host.getModuleResolutionCache?.(); } else { moduleResolutionCache = createModuleResolutionCache(currentDirectory, getCanonicalFileName, options); diff --git a/src/compiler/tsbuildPublic.ts b/src/compiler/tsbuildPublic.ts index b92741a3de8dc..e8c0b689c62f1 100644 --- a/src/compiler/tsbuildPublic.ts +++ b/src/compiler/tsbuildPublic.ts @@ -284,6 +284,7 @@ namespace ts { const loader = (moduleName: string, containingFile: string, redirectedReference: ResolvedProjectReference | undefined) => resolveModuleName(moduleName, containingFile, state.projectCompilerOptions, compilerHost, moduleResolutionCache, redirectedReference).resolvedModule!; compilerHost.resolveModuleNames = (moduleNames, containingFile, _reusedNames, redirectedReference) => loadWithLocalCache(Debug.checkEachDefined(moduleNames), containingFile, redirectedReference, loader); + compilerHost.getModuleResolutionCache = () => moduleResolutionCache; } if (!compilerHost.resolveTypeReferenceDirectives) { const loader = (moduleName: string, containingFile: string, redirectedReference: ResolvedProjectReference | undefined) => resolveTypeReferenceDirective(moduleName, containingFile, state.projectCompilerOptions, compilerHost, redirectedReference, state.typeReferenceDirectiveResolutionCache).resolvedTypeReferenceDirective!; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 3652e55cd5e67..829498244e4e9 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -6609,6 +6609,10 @@ namespace ts { * 'throw new Error("NotImplemented")' */ resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedModule | undefined)[]; + /** + * Returns the module resolution cache used by a provided `resolveModuleNames` implementation so that any non-name module resolution operations (eg, package.json lookup) can reuse it + */ + getModuleResolutionCache?(): ModuleResolutionCache | undefined; /** * This method is a companion for 'resolveModuleNames' and is used to resolve 'types' references to actual type declaration files */ diff --git a/src/testRunner/unittests/tsbuild/moduleResolution.ts b/src/testRunner/unittests/tsbuild/moduleResolution.ts index 0bf612f192c89..0ac722293626f 100644 --- a/src/testRunner/unittests/tsbuild/moduleResolution.ts +++ b/src/testRunner/unittests/tsbuild/moduleResolution.ts @@ -148,8 +148,8 @@ namespace ts.tscWatch { { caption: "removes those errors when a package file is changed to cjs extensions", change: sys => { - replaceFileText(sys, `${projectRoot}/packages/pkg2/package.json`, `"main": "build/index.js"`, `"main": "build/index.cjs"`); - sys.renameFile(`${projectRoot}/packages/pkg2/index.ts`, `${projectRoot}/packages/pkg2/index.cts`) + replaceFileText(sys, `${projectRoot}/packages/pkg2/package.json`, `"build/index.js"`, `"build/index.cjs"`); + sys.renameFile(`${projectRoot}/packages/pkg2/index.ts`, `${projectRoot}/packages/pkg2/index.cts`); }, timeouts: runQueuedTimeoutCallbacks, }, diff --git a/src/testRunner/unittests/tscWatch/incremental.ts b/src/testRunner/unittests/tscWatch/incremental.ts index bc6e541815a5c..8da2d0c09c4ba 100644 --- a/src/testRunner/unittests/tscWatch/incremental.ts +++ b/src/testRunner/unittests/tscWatch/incremental.ts @@ -163,16 +163,19 @@ namespace ts.tscWatch { version: system.createHash(libFile.content), signature: system.createHash(libFile.content), affectsGlobalScope: true, + impliedFormat: undefined, }); assert.deepEqual(state.fileInfos.get(file1.path as Path), { version: system.createHash(file1.content), signature: system.createHash(file1.content), affectsGlobalScope: undefined, + impliedFormat: undefined, }); assert.deepEqual(state.fileInfos.get(file2.path as Path), { version: system.createHash(fileModified.content), signature: system.createHash(fileModified.content), affectsGlobalScope: undefined, + impliedFormat: undefined, }); assert.deepEqual(state.compilerOptions, { diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 8474b288eb1cc..1f4f871ddf5b5 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -3163,6 +3163,10 @@ declare namespace ts { getNewLine(): string; readDirectory?(rootDir: string, extensions: readonly string[], excludes: readonly string[] | undefined, includes: readonly string[], depth?: number): string[]; resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedModule | undefined)[]; + /** + * Returns the module resolution cache used by a provided `resolveModuleNames` implementation so that any non-name module resolution operations (eg, package.json lookup) can reuse it + */ + getModuleResolutionCache?(): ModuleResolutionCache | undefined; /** * This method is a companion for 'resolveModuleNames' and is used to resolve 'types' references to actual type declaration files */ diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 273ac73c3011b..c96afc78fcbfd 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -3163,6 +3163,10 @@ declare namespace ts { getNewLine(): string; readDirectory?(rootDir: string, extensions: readonly string[], excludes: readonly string[] | undefined, includes: readonly string[], depth?: number): string[]; resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions): (ResolvedModule | undefined)[]; + /** + * Returns the module resolution cache used by a provided `resolveModuleNames` implementation so that any non-name module resolution operations (eg, package.json lookup) can reuse it + */ + getModuleResolutionCache?(): ModuleResolutionCache | undefined; /** * This method is a companion for 'resolveModuleNames' and is used to resolve 'types' references to actual type declaration files */ diff --git a/tests/baselines/reference/tsbuild/watchMode/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-cts-and-mts-extensions.js b/tests/baselines/reference/tsbuild/watchMode/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-cts-and-mts-extensions.js index 1d8fe17b077e9..1a445f232047e 100644 --- a/tests/baselines/reference/tsbuild/watchMode/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-cts-and-mts-extensions.js +++ b/tests/baselines/reference/tsbuild/watchMode/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-cts-and-mts-extensions.js @@ -95,8 +95,7 @@ File '/user/username/projects/myproject/node_modules/pkg2/build/index.d.ts' exis Resolving real path for '/user/username/projects/myproject/node_modules/pkg2/build/index.d.ts', result '/user/username/projects/myproject/packages/pkg2/build/index.d.ts'. ======== Module name 'pkg2' was successfully resolved to '/user/username/projects/myproject/packages/pkg2/build/index.d.ts' with Package ID 'pkg2/build/index.d.ts@1.0.0'. ======== File '/user/username/projects/myproject/packages/pkg2/build/package.json' does not exist. -Found 'package.json' at '/user/username/projects/myproject/packages/pkg2/package.json'. -'package.json' does not have a 'typesVersions' field. +File '/user/username/projects/myproject/packages/pkg2/package.json' exists according to earlier cached lookups. ======== Resolving module './const.cjs' from '/user/username/projects/myproject/packages/pkg2/build/index.d.ts'. ======== Using compiler options of project reference redirect '/user/username/projects/myproject/packages/pkg2/tsconfig.json'. Module resolution kind is not specified, using 'Node12'. @@ -108,9 +107,9 @@ File name '/user/username/projects/myproject/packages/pkg2/build/const.cjs' has File '/user/username/projects/myproject/packages/pkg2/build/const.cts' does not exist. File '/user/username/projects/myproject/packages/pkg2/build/const.d.cts' exist - use it as a name resolution result. ======== Module name './const.cjs' was successfully resolved to '/user/username/projects/myproject/packages/pkg2/build/const.d.cts'. ======== -File '/a/lib/package.json' does not exist. -File '/a/package.json' does not exist. -File '/package.json' does not exist. +File '/a/lib/package.json' does not exist according to earlier cached lookups. +File '/a/package.json' does not exist according to earlier cached lookups. +File '/package.json' does not exist according to earlier cached lookups. [12:01:07 AM] Found 0 errors. Watching for file changes. @@ -158,12 +157,26 @@ WatchedFiles:: {"fileName":"/user/username/projects/myproject/packages/pkg2/const.cts","pollingInterval":250} /user/username/projects/myproject/packages/pkg2/index.ts: {"fileName":"/user/username/projects/myproject/packages/pkg2/index.ts","pollingInterval":250} +/user/username/projects/myproject/packages/pkg2/package.json: + {"fileName":"/user/username/projects/myproject/packages/pkg2/package.json","pollingInterval":250} + {"fileName":"/user/username/projects/myproject/packages/pkg2/package.json","pollingInterval":250} +/a/lib/package.json: + {"fileName":"/a/lib/package.json","pollingInterval":250} + {"fileName":"/a/lib/package.json","pollingInterval":250} +/a/package.json: + {"fileName":"/a/package.json","pollingInterval":250} + {"fileName":"/a/package.json","pollingInterval":250} +/package.json: + {"fileName":"/package.json","pollingInterval":250} + {"fileName":"/package.json","pollingInterval":250} /user/username/projects/myproject/packages/pkg1/tsconfig.json: {"fileName":"/user/username/projects/myproject/packages/pkg1/tsconfig.json","pollingInterval":250} /user/username/projects/myproject/packages/pkg1/index.ts: {"fileName":"/user/username/projects/myproject/packages/pkg1/index.ts","pollingInterval":250} -/user/username/projects/myproject/packages/pkg2/package.json: - {"fileName":"/user/username/projects/myproject/packages/pkg2/package.json","pollingInterval":250} +/user/username/projects/myproject/packages/pkg1/package.json: + {"fileName":"/user/username/projects/myproject/packages/pkg1/package.json","pollingInterval":250} +/user/username/projects/myproject/packages/pkg2/build/package.json: + {"fileName":"/user/username/projects/myproject/packages/pkg2/build/package.json","pollingInterval":250} FsWatches:: @@ -193,7 +206,7 @@ export type { TheNum } from './const.cjs'; //// [/user/username/projects/myproject/packages/pkg2/build/tsconfig.tsbuildinfo] -{"program":{"fileNames":["../../../../../../../a/lib/lib.es2020.full.d.ts","../const.cts","../index.ts"],"fileInfos":[{"version":"-7698705165-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }","affectsGlobalScope":true},"-11202312776-export type TheNum = 42;","-9668872159-export type { TheNum } from './const.cjs';"],"options":{"composite":true,"module":100,"outDir":"./"},"fileIdsList":[[2]],"referencedMap":[[3,1]],"exportedModulesMap":[[3,1]],"semanticDiagnosticsPerFile":[1,2,3]},"version":"FakeTSVersion"} +{"program":{"fileNames":["../../../../../../../a/lib/lib.es2020.full.d.ts","../const.cts","../index.ts"],"fileInfos":[{"version":"-7698705165-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }","affectsGlobalScope":true,"impliedFormat":1},"-11202312776-export type TheNum = 42;","-9668872159-export type { TheNum } from './const.cjs';"],"options":{"composite":true,"module":100,"outDir":"./"},"fileIdsList":[[2]],"referencedMap":[[3,1]],"exportedModulesMap":[[3,1]],"semanticDiagnosticsPerFile":[1,2,3]},"version":"FakeTSVersion"} //// [/user/username/projects/myproject/packages/pkg2/build/tsconfig.tsbuildinfo.readable.baseline.txt] { @@ -212,7 +225,8 @@ export type { TheNum } from './const.cjs'; "../../../../../../../a/lib/lib.es2020.full.d.ts": { "version": "-7698705165-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }", "signature": "-7698705165-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }", - "affectsGlobalScope": true + "affectsGlobalScope": true, + "impliedFormat": 1 }, "../const.cts": { "version": "-11202312776-export type TheNum = 42;", @@ -245,7 +259,7 @@ export type { TheNum } from './const.cjs'; ] }, "version": "FakeTSVersion", - "size": 808 + "size": 826 } //// [/user/username/projects/myproject/packages/pkg1/build/index.js] @@ -261,6 +275,79 @@ Input:: Output:: +>> Screen clear +[12:01:11 AM] File change detected. Starting incremental compilation... + +[12:01:12 AM] Project 'packages/pkg1/tsconfig.json' is out of date because oldest output 'packages/pkg1/build/index.js' is older than newest input 'packages/pkg2' + +[12:01:13 AM] Building project '/user/username/projects/myproject/packages/pkg1/tsconfig.json'... + +Found 'package.json' at '/user/username/projects/myproject/packages/pkg1/package.json'. +'package.json' does not have a 'typesVersions' field. +======== Resolving module 'pkg2' from '/user/username/projects/myproject/packages/pkg1/index.ts'. ======== +Module resolution kind is not specified, using 'Node12'. +Loading module 'pkg2' from 'node_modules' folder, target file type 'TypeScript'. +Directory '/user/username/projects/myproject/packages/pkg1/node_modules' does not exist, skipping all lookups in it. +Directory '/user/username/projects/myproject/packages/node_modules' does not exist, skipping all lookups in it. +Found 'package.json' at '/user/username/projects/myproject/node_modules/pkg2/package.json'. +'package.json' does not have a 'typesVersions' field. +File '/user/username/projects/myproject/node_modules/pkg2.ts' does not exist. +File '/user/username/projects/myproject/node_modules/pkg2.tsx' does not exist. +File '/user/username/projects/myproject/node_modules/pkg2.d.ts' does not exist. +'package.json' does not have a 'typings' field. +'package.json' does not have a 'types' field. +'package.json' has 'main' field 'build/index.js' that references '/user/username/projects/myproject/node_modules/pkg2/build/index.js'. +File '/user/username/projects/myproject/node_modules/pkg2/build/index.js' exist - use it as a name resolution result. +File '/user/username/projects/myproject/node_modules/pkg2/build/index.js' has an unsupported extension, so skipping it. +Loading module as file / folder, candidate module location '/user/username/projects/myproject/node_modules/pkg2/build/index.js', target file type 'TypeScript'. +File '/user/username/projects/myproject/node_modules/pkg2/build/index.js.ts' does not exist. +File '/user/username/projects/myproject/node_modules/pkg2/build/index.js.tsx' does not exist. +File '/user/username/projects/myproject/node_modules/pkg2/build/index.js.d.ts' does not exist. +File name '/user/username/projects/myproject/node_modules/pkg2/build/index.js' has a '.js' extension - stripping it. +File '/user/username/projects/myproject/node_modules/pkg2/build/index.ts' does not exist. +File '/user/username/projects/myproject/node_modules/pkg2/build/index.tsx' does not exist. +File '/user/username/projects/myproject/node_modules/pkg2/build/index.d.ts' exist - use it as a name resolution result. +Resolving real path for '/user/username/projects/myproject/node_modules/pkg2/build/index.d.ts', result '/user/username/projects/myproject/packages/pkg2/build/index.d.ts'. +======== Module name 'pkg2' was successfully resolved to '/user/username/projects/myproject/packages/pkg2/build/index.d.ts' with Package ID 'pkg2/build/index.d.ts@1.0.0'. ======== +File '/user/username/projects/myproject/packages/pkg2/build/package.json' does not exist. +Found 'package.json' at '/user/username/projects/myproject/packages/pkg2/package.json'. +'package.json' does not have a 'typesVersions' field. +======== Resolving module './const.cjs' from '/user/username/projects/myproject/packages/pkg2/build/index.d.ts'. ======== +Using compiler options of project reference redirect '/user/username/projects/myproject/packages/pkg2/tsconfig.json'. +Module resolution kind is not specified, using 'Node12'. +Loading module as file / folder, candidate module location '/user/username/projects/myproject/packages/pkg2/build/const.cjs', target file type 'TypeScript'. +File '/user/username/projects/myproject/packages/pkg2/build/const.cjs.ts' does not exist. +File '/user/username/projects/myproject/packages/pkg2/build/const.cjs.tsx' does not exist. +File '/user/username/projects/myproject/packages/pkg2/build/const.cjs.d.ts' does not exist. +File name '/user/username/projects/myproject/packages/pkg2/build/const.cjs' has a '.cjs' extension - stripping it. +File '/user/username/projects/myproject/packages/pkg2/build/const.cts' does not exist. +File '/user/username/projects/myproject/packages/pkg2/build/const.d.cts' exist - use it as a name resolution result. +======== Module name './const.cjs' was successfully resolved to '/user/username/projects/myproject/packages/pkg2/build/const.d.cts'. ======== +File '/a/lib/package.json' does not exist. +File '/a/package.json' does not exist. +File '/package.json' does not exist. +packages/pkg1/index.ts:1:29 - error TS1445: Module 'pkg2' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. + +1 import type { TheNum } from 'pkg2' +   ~~~~~~ + +[12:01:14 AM] Found 1 error. Watching for file changes. + + + +Program root files: ["/user/username/projects/myproject/packages/pkg1/index.ts"] +Program options: {"outDir":"/user/username/projects/myproject/packages/pkg1/build","module":100,"watch":true,"traceResolution":true,"configFilePath":"/user/username/projects/myproject/packages/pkg1/tsconfig.json"} +Program structureReused: Not +Program files:: +/a/lib/lib.es2020.full.d.ts +/user/username/projects/myproject/packages/pkg2/build/index.d.ts +/user/username/projects/myproject/packages/pkg1/index.ts + +Semantic diagnostics in builder refreshed for:: +/user/username/projects/myproject/packages/pkg1/index.ts + +Shape signatures in builder refreshed for:: +/user/username/projects/myproject/packages/pkg1/index.ts (computed .d.ts) WatchedFiles:: /user/username/projects/myproject/packages/pkg2/tsconfig.json: @@ -269,12 +356,26 @@ WatchedFiles:: {"fileName":"/user/username/projects/myproject/packages/pkg2/const.cts","pollingInterval":250} /user/username/projects/myproject/packages/pkg2/index.ts: {"fileName":"/user/username/projects/myproject/packages/pkg2/index.ts","pollingInterval":250} +/user/username/projects/myproject/packages/pkg2/package.json: + {"fileName":"/user/username/projects/myproject/packages/pkg2/package.json","pollingInterval":250} + {"fileName":"/user/username/projects/myproject/packages/pkg2/package.json","pollingInterval":250} +/a/lib/package.json: + {"fileName":"/a/lib/package.json","pollingInterval":250} + {"fileName":"/a/lib/package.json","pollingInterval":250} +/a/package.json: + {"fileName":"/a/package.json","pollingInterval":250} + {"fileName":"/a/package.json","pollingInterval":250} +/package.json: + {"fileName":"/package.json","pollingInterval":250} + {"fileName":"/package.json","pollingInterval":250} /user/username/projects/myproject/packages/pkg1/tsconfig.json: {"fileName":"/user/username/projects/myproject/packages/pkg1/tsconfig.json","pollingInterval":250} /user/username/projects/myproject/packages/pkg1/index.ts: {"fileName":"/user/username/projects/myproject/packages/pkg1/index.ts","pollingInterval":250} -/user/username/projects/myproject/packages/pkg2/package.json: - {"fileName":"/user/username/projects/myproject/packages/pkg2/package.json","pollingInterval":250} +/user/username/projects/myproject/packages/pkg1/package.json: + {"fileName":"/user/username/projects/myproject/packages/pkg1/package.json","pollingInterval":250} +/user/username/projects/myproject/packages/pkg2/build/package.json: + {"fileName":"/user/username/projects/myproject/packages/pkg2/build/package.json","pollingInterval":250} FsWatches:: @@ -295,6 +396,74 @@ Input:: Output:: +>> Screen clear +[12:01:18 AM] File change detected. Starting incremental compilation... + +[12:01:19 AM] Project 'packages/pkg1/tsconfig.json' is out of date because oldest output 'packages/pkg1/build/index.js' is older than newest input 'packages/pkg2' + +[12:01:20 AM] Building project '/user/username/projects/myproject/packages/pkg1/tsconfig.json'... + +Found 'package.json' at '/user/username/projects/myproject/packages/pkg1/package.json'. +'package.json' does not have a 'typesVersions' field. +======== Resolving module 'pkg2' from '/user/username/projects/myproject/packages/pkg1/index.ts'. ======== +Module resolution kind is not specified, using 'Node12'. +Loading module 'pkg2' from 'node_modules' folder, target file type 'TypeScript'. +Directory '/user/username/projects/myproject/packages/pkg1/node_modules' does not exist, skipping all lookups in it. +Directory '/user/username/projects/myproject/packages/node_modules' does not exist, skipping all lookups in it. +Found 'package.json' at '/user/username/projects/myproject/node_modules/pkg2/package.json'. +'package.json' does not have a 'typesVersions' field. +File '/user/username/projects/myproject/node_modules/pkg2.ts' does not exist. +File '/user/username/projects/myproject/node_modules/pkg2.tsx' does not exist. +File '/user/username/projects/myproject/node_modules/pkg2.d.ts' does not exist. +'package.json' does not have a 'typings' field. +'package.json' does not have a 'types' field. +'package.json' has 'main' field 'build/index.js' that references '/user/username/projects/myproject/node_modules/pkg2/build/index.js'. +File '/user/username/projects/myproject/node_modules/pkg2/build/index.js' exist - use it as a name resolution result. +File '/user/username/projects/myproject/node_modules/pkg2/build/index.js' has an unsupported extension, so skipping it. +Loading module as file / folder, candidate module location '/user/username/projects/myproject/node_modules/pkg2/build/index.js', target file type 'TypeScript'. +File '/user/username/projects/myproject/node_modules/pkg2/build/index.js.ts' does not exist. +File '/user/username/projects/myproject/node_modules/pkg2/build/index.js.tsx' does not exist. +File '/user/username/projects/myproject/node_modules/pkg2/build/index.js.d.ts' does not exist. +File name '/user/username/projects/myproject/node_modules/pkg2/build/index.js' has a '.js' extension - stripping it. +File '/user/username/projects/myproject/node_modules/pkg2/build/index.ts' does not exist. +File '/user/username/projects/myproject/node_modules/pkg2/build/index.tsx' does not exist. +File '/user/username/projects/myproject/node_modules/pkg2/build/index.d.ts' exist - use it as a name resolution result. +Resolving real path for '/user/username/projects/myproject/node_modules/pkg2/build/index.d.ts', result '/user/username/projects/myproject/packages/pkg2/build/index.d.ts'. +======== Module name 'pkg2' was successfully resolved to '/user/username/projects/myproject/packages/pkg2/build/index.d.ts' with Package ID 'pkg2/build/index.d.ts@1.0.0'. ======== +File '/user/username/projects/myproject/packages/pkg2/build/package.json' does not exist. +Found 'package.json' at '/user/username/projects/myproject/packages/pkg2/package.json'. +'package.json' does not have a 'typesVersions' field. +======== Resolving module './const.cjs' from '/user/username/projects/myproject/packages/pkg2/build/index.d.ts'. ======== +Using compiler options of project reference redirect '/user/username/projects/myproject/packages/pkg2/tsconfig.json'. +Module resolution kind is not specified, using 'Node12'. +Loading module as file / folder, candidate module location '/user/username/projects/myproject/packages/pkg2/build/const.cjs', target file type 'TypeScript'. +File '/user/username/projects/myproject/packages/pkg2/build/const.cjs.ts' does not exist. +File '/user/username/projects/myproject/packages/pkg2/build/const.cjs.tsx' does not exist. +File '/user/username/projects/myproject/packages/pkg2/build/const.cjs.d.ts' does not exist. +File name '/user/username/projects/myproject/packages/pkg2/build/const.cjs' has a '.cjs' extension - stripping it. +File '/user/username/projects/myproject/packages/pkg2/build/const.cts' does not exist. +File '/user/username/projects/myproject/packages/pkg2/build/const.d.cts' exist - use it as a name resolution result. +======== Module name './const.cjs' was successfully resolved to '/user/username/projects/myproject/packages/pkg2/build/const.d.cts'. ======== +File '/a/lib/package.json' does not exist. +File '/a/package.json' does not exist. +File '/package.json' does not exist. +[12:01:24 AM] Found 0 errors. Watching for file changes. + + + +Program root files: ["/user/username/projects/myproject/packages/pkg1/index.ts"] +Program options: {"outDir":"/user/username/projects/myproject/packages/pkg1/build","module":100,"watch":true,"traceResolution":true,"configFilePath":"/user/username/projects/myproject/packages/pkg1/tsconfig.json"} +Program structureReused: Not +Program files:: +/a/lib/lib.es2020.full.d.ts +/user/username/projects/myproject/packages/pkg2/build/index.d.ts +/user/username/projects/myproject/packages/pkg1/index.ts + +Semantic diagnostics in builder refreshed for:: +/user/username/projects/myproject/packages/pkg1/index.ts + +Shape signatures in builder refreshed for:: +/user/username/projects/myproject/packages/pkg1/index.ts (computed .d.ts) WatchedFiles:: /user/username/projects/myproject/packages/pkg2/tsconfig.json: @@ -303,12 +472,26 @@ WatchedFiles:: {"fileName":"/user/username/projects/myproject/packages/pkg2/const.cts","pollingInterval":250} /user/username/projects/myproject/packages/pkg2/index.ts: {"fileName":"/user/username/projects/myproject/packages/pkg2/index.ts","pollingInterval":250} +/user/username/projects/myproject/packages/pkg2/package.json: + {"fileName":"/user/username/projects/myproject/packages/pkg2/package.json","pollingInterval":250} + {"fileName":"/user/username/projects/myproject/packages/pkg2/package.json","pollingInterval":250} +/a/lib/package.json: + {"fileName":"/a/lib/package.json","pollingInterval":250} + {"fileName":"/a/lib/package.json","pollingInterval":250} +/a/package.json: + {"fileName":"/a/package.json","pollingInterval":250} + {"fileName":"/a/package.json","pollingInterval":250} +/package.json: + {"fileName":"/package.json","pollingInterval":250} + {"fileName":"/package.json","pollingInterval":250} /user/username/projects/myproject/packages/pkg1/tsconfig.json: {"fileName":"/user/username/projects/myproject/packages/pkg1/tsconfig.json","pollingInterval":250} /user/username/projects/myproject/packages/pkg1/index.ts: {"fileName":"/user/username/projects/myproject/packages/pkg1/index.ts","pollingInterval":250} -/user/username/projects/myproject/packages/pkg2/package.json: - {"fileName":"/user/username/projects/myproject/packages/pkg2/package.json","pollingInterval":250} +/user/username/projects/myproject/packages/pkg1/package.json: + {"fileName":"/user/username/projects/myproject/packages/pkg1/package.json","pollingInterval":250} +/user/username/projects/myproject/packages/pkg2/build/package.json: + {"fileName":"/user/username/projects/myproject/packages/pkg2/build/package.json","pollingInterval":250} FsWatches:: @@ -320,6 +503,7 @@ FsWatchesRecursive:: exitCode:: ExitStatus.undefined +//// [/user/username/projects/myproject/packages/pkg1/build/index.js] file written with same contents Change:: reports import errors after change to package file @@ -329,6 +513,79 @@ Input:: Output:: +>> Screen clear +[12:01:28 AM] File change detected. Starting incremental compilation... + +[12:01:29 AM] Project 'packages/pkg1/tsconfig.json' is out of date because oldest output 'packages/pkg1/build/index.js' is older than newest input 'packages/pkg2' + +[12:01:30 AM] Building project '/user/username/projects/myproject/packages/pkg1/tsconfig.json'... + +Found 'package.json' at '/user/username/projects/myproject/packages/pkg1/package.json'. +'package.json' does not have a 'typesVersions' field. +======== Resolving module 'pkg2' from '/user/username/projects/myproject/packages/pkg1/index.ts'. ======== +Module resolution kind is not specified, using 'Node12'. +Loading module 'pkg2' from 'node_modules' folder, target file type 'TypeScript'. +Directory '/user/username/projects/myproject/packages/pkg1/node_modules' does not exist, skipping all lookups in it. +Directory '/user/username/projects/myproject/packages/node_modules' does not exist, skipping all lookups in it. +Found 'package.json' at '/user/username/projects/myproject/node_modules/pkg2/package.json'. +'package.json' does not have a 'typesVersions' field. +File '/user/username/projects/myproject/node_modules/pkg2.ts' does not exist. +File '/user/username/projects/myproject/node_modules/pkg2.tsx' does not exist. +File '/user/username/projects/myproject/node_modules/pkg2.d.ts' does not exist. +'package.json' does not have a 'typings' field. +'package.json' does not have a 'types' field. +'package.json' has 'main' field 'build/index.js' that references '/user/username/projects/myproject/node_modules/pkg2/build/index.js'. +File '/user/username/projects/myproject/node_modules/pkg2/build/index.js' exist - use it as a name resolution result. +File '/user/username/projects/myproject/node_modules/pkg2/build/index.js' has an unsupported extension, so skipping it. +Loading module as file / folder, candidate module location '/user/username/projects/myproject/node_modules/pkg2/build/index.js', target file type 'TypeScript'. +File '/user/username/projects/myproject/node_modules/pkg2/build/index.js.ts' does not exist. +File '/user/username/projects/myproject/node_modules/pkg2/build/index.js.tsx' does not exist. +File '/user/username/projects/myproject/node_modules/pkg2/build/index.js.d.ts' does not exist. +File name '/user/username/projects/myproject/node_modules/pkg2/build/index.js' has a '.js' extension - stripping it. +File '/user/username/projects/myproject/node_modules/pkg2/build/index.ts' does not exist. +File '/user/username/projects/myproject/node_modules/pkg2/build/index.tsx' does not exist. +File '/user/username/projects/myproject/node_modules/pkg2/build/index.d.ts' exist - use it as a name resolution result. +Resolving real path for '/user/username/projects/myproject/node_modules/pkg2/build/index.d.ts', result '/user/username/projects/myproject/packages/pkg2/build/index.d.ts'. +======== Module name 'pkg2' was successfully resolved to '/user/username/projects/myproject/packages/pkg2/build/index.d.ts' with Package ID 'pkg2/build/index.d.ts@1.0.0'. ======== +File '/user/username/projects/myproject/packages/pkg2/build/package.json' does not exist. +Found 'package.json' at '/user/username/projects/myproject/packages/pkg2/package.json'. +'package.json' does not have a 'typesVersions' field. +======== Resolving module './const.cjs' from '/user/username/projects/myproject/packages/pkg2/build/index.d.ts'. ======== +Using compiler options of project reference redirect '/user/username/projects/myproject/packages/pkg2/tsconfig.json'. +Module resolution kind is not specified, using 'Node12'. +Loading module as file / folder, candidate module location '/user/username/projects/myproject/packages/pkg2/build/const.cjs', target file type 'TypeScript'. +File '/user/username/projects/myproject/packages/pkg2/build/const.cjs.ts' does not exist. +File '/user/username/projects/myproject/packages/pkg2/build/const.cjs.tsx' does not exist. +File '/user/username/projects/myproject/packages/pkg2/build/const.cjs.d.ts' does not exist. +File name '/user/username/projects/myproject/packages/pkg2/build/const.cjs' has a '.cjs' extension - stripping it. +File '/user/username/projects/myproject/packages/pkg2/build/const.cts' does not exist. +File '/user/username/projects/myproject/packages/pkg2/build/const.d.cts' exist - use it as a name resolution result. +======== Module name './const.cjs' was successfully resolved to '/user/username/projects/myproject/packages/pkg2/build/const.d.cts'. ======== +File '/a/lib/package.json' does not exist. +File '/a/package.json' does not exist. +File '/package.json' does not exist. +packages/pkg1/index.ts:1:29 - error TS1445: Module 'pkg2' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. + +1 import type { TheNum } from 'pkg2' +   ~~~~~~ + +[12:01:31 AM] Found 1 error. Watching for file changes. + + + +Program root files: ["/user/username/projects/myproject/packages/pkg1/index.ts"] +Program options: {"outDir":"/user/username/projects/myproject/packages/pkg1/build","module":100,"watch":true,"traceResolution":true,"configFilePath":"/user/username/projects/myproject/packages/pkg1/tsconfig.json"} +Program structureReused: Not +Program files:: +/a/lib/lib.es2020.full.d.ts +/user/username/projects/myproject/packages/pkg2/build/index.d.ts +/user/username/projects/myproject/packages/pkg1/index.ts + +Semantic diagnostics in builder refreshed for:: +/user/username/projects/myproject/packages/pkg1/index.ts + +Shape signatures in builder refreshed for:: +/user/username/projects/myproject/packages/pkg1/index.ts (computed .d.ts) WatchedFiles:: /user/username/projects/myproject/packages/pkg2/tsconfig.json: @@ -337,12 +594,26 @@ WatchedFiles:: {"fileName":"/user/username/projects/myproject/packages/pkg2/const.cts","pollingInterval":250} /user/username/projects/myproject/packages/pkg2/index.ts: {"fileName":"/user/username/projects/myproject/packages/pkg2/index.ts","pollingInterval":250} +/user/username/projects/myproject/packages/pkg2/package.json: + {"fileName":"/user/username/projects/myproject/packages/pkg2/package.json","pollingInterval":250} + {"fileName":"/user/username/projects/myproject/packages/pkg2/package.json","pollingInterval":250} +/a/lib/package.json: + {"fileName":"/a/lib/package.json","pollingInterval":250} + {"fileName":"/a/lib/package.json","pollingInterval":250} +/a/package.json: + {"fileName":"/a/package.json","pollingInterval":250} + {"fileName":"/a/package.json","pollingInterval":250} +/package.json: + {"fileName":"/package.json","pollingInterval":250} + {"fileName":"/package.json","pollingInterval":250} /user/username/projects/myproject/packages/pkg1/tsconfig.json: {"fileName":"/user/username/projects/myproject/packages/pkg1/tsconfig.json","pollingInterval":250} /user/username/projects/myproject/packages/pkg1/index.ts: {"fileName":"/user/username/projects/myproject/packages/pkg1/index.ts","pollingInterval":250} -/user/username/projects/myproject/packages/pkg2/package.json: - {"fileName":"/user/username/projects/myproject/packages/pkg2/package.json","pollingInterval":250} +/user/username/projects/myproject/packages/pkg1/package.json: + {"fileName":"/user/username/projects/myproject/packages/pkg1/package.json","pollingInterval":250} +/user/username/projects/myproject/packages/pkg2/build/package.json: + {"fileName":"/user/username/projects/myproject/packages/pkg2/build/package.json","pollingInterval":250} FsWatches:: @@ -358,7 +629,9 @@ exitCode:: ExitStatus.undefined Change:: removes those errors when a package file is changed to cjs extensions Input:: -//// [/user/username/projects/myproject/packages/pkg2/package.json] file written with same contents +//// [/user/username/projects/myproject/packages/pkg2/package.json] +{"name":"pkg2","version":"1.0.0","main":"build/index.cjs","type":"module"} + //// [/user/username/projects/myproject/packages/pkg2/index.cts] export type { TheNum } from './const.cjs'; @@ -366,11 +639,11 @@ export type { TheNum } from './const.cjs'; Output:: >> Screen clear -[12:01:23 AM] File change detected. Starting incremental compilation... +[12:01:38 AM] File change detected. Starting incremental compilation... -[12:01:24 AM] Project 'packages/pkg2/tsconfig.json' is out of date because oldest output 'packages/pkg2/build/const.cjs' is older than newest input 'packages/pkg2/index.cts' +[12:01:39 AM] Project 'packages/pkg2/tsconfig.json' is out of date because oldest output 'packages/pkg2/build/const.cjs' is older than newest input 'packages/pkg2/index.cts' -[12:01:25 AM] Building project '/user/username/projects/myproject/packages/pkg2/tsconfig.json'... +[12:01:40 AM] Building project '/user/username/projects/myproject/packages/pkg2/tsconfig.json'... ======== Resolving module './const.cjs' from '/user/username/projects/myproject/packages/pkg2/index.cts'. ======== Module resolution kind is not specified, using 'Node12'. @@ -384,7 +657,7 @@ File '/user/username/projects/myproject/packages/pkg2/const.cts' exist - use it File '/a/lib/package.json' does not exist. File '/a/package.json' does not exist. File '/package.json' does not exist. -[12:01:34 AM] Updating unchanged output timestamps of project '/user/username/projects/myproject/packages/pkg2/tsconfig.json'... +[12:01:49 AM] Updating unchanged output timestamps of project '/user/username/projects/myproject/packages/pkg2/tsconfig.json'... @@ -407,12 +680,26 @@ WatchedFiles:: {"fileName":"/user/username/projects/myproject/packages/pkg2/tsconfig.json","pollingInterval":250} /user/username/projects/myproject/packages/pkg2/const.cts: {"fileName":"/user/username/projects/myproject/packages/pkg2/const.cts","pollingInterval":250} +/user/username/projects/myproject/packages/pkg2/package.json: + {"fileName":"/user/username/projects/myproject/packages/pkg2/package.json","pollingInterval":250} + {"fileName":"/user/username/projects/myproject/packages/pkg2/package.json","pollingInterval":250} +/a/lib/package.json: + {"fileName":"/a/lib/package.json","pollingInterval":250} + {"fileName":"/a/lib/package.json","pollingInterval":250} +/a/package.json: + {"fileName":"/a/package.json","pollingInterval":250} + {"fileName":"/a/package.json","pollingInterval":250} +/package.json: + {"fileName":"/package.json","pollingInterval":250} + {"fileName":"/package.json","pollingInterval":250} /user/username/projects/myproject/packages/pkg1/tsconfig.json: {"fileName":"/user/username/projects/myproject/packages/pkg1/tsconfig.json","pollingInterval":250} /user/username/projects/myproject/packages/pkg1/index.ts: {"fileName":"/user/username/projects/myproject/packages/pkg1/index.ts","pollingInterval":250} -/user/username/projects/myproject/packages/pkg2/package.json: - {"fileName":"/user/username/projects/myproject/packages/pkg2/package.json","pollingInterval":250} +/user/username/projects/myproject/packages/pkg1/package.json: + {"fileName":"/user/username/projects/myproject/packages/pkg1/package.json","pollingInterval":250} +/user/username/projects/myproject/packages/pkg2/build/package.json: + {"fileName":"/user/username/projects/myproject/packages/pkg2/build/package.json","pollingInterval":250} /user/username/projects/myproject/packages/pkg2/index.cts: {"fileName":"/user/username/projects/myproject/packages/pkg2/index.cts","pollingInterval":250} @@ -429,7 +716,7 @@ exitCode:: ExitStatus.undefined //// [/user/username/projects/myproject/packages/pkg2/build/const.cjs] file changed its modified time //// [/user/username/projects/myproject/packages/pkg2/build/const.d.cts] file changed its modified time //// [/user/username/projects/myproject/packages/pkg2/build/tsconfig.tsbuildinfo] -{"program":{"fileNames":["../../../../../../../a/lib/lib.es2020.full.d.ts","../const.cts","../index.cts"],"fileInfos":[{"version":"-7698705165-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }","affectsGlobalScope":true},"-11202312776-export type TheNum = 42;",{"version":"-9668872159-export type { TheNum } from './const.cjs';","signature":"-9835135925-export type { TheNum } from './const.cjs';\n"}],"options":{"composite":true,"module":100,"outDir":"./"},"fileIdsList":[[2]],"referencedMap":[[3,1]],"exportedModulesMap":[[3,1]],"semanticDiagnosticsPerFile":[1,2,3]},"version":"FakeTSVersion"} +{"program":{"fileNames":["../../../../../../../a/lib/lib.es2020.full.d.ts","../const.cts","../index.cts"],"fileInfos":[{"version":"-7698705165-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }","affectsGlobalScope":true,"impliedFormat":1},"-11202312776-export type TheNum = 42;",{"version":"-9668872159-export type { TheNum } from './const.cjs';","signature":"-9835135925-export type { TheNum } from './const.cjs';\n","impliedFormat":1}],"options":{"composite":true,"module":100,"outDir":"./"},"fileIdsList":[[2]],"referencedMap":[[3,1]],"exportedModulesMap":[[3,1]],"semanticDiagnosticsPerFile":[1,2,3]},"version":"FakeTSVersion"} //// [/user/username/projects/myproject/packages/pkg2/build/tsconfig.tsbuildinfo.readable.baseline.txt] { @@ -448,7 +735,8 @@ exitCode:: ExitStatus.undefined "../../../../../../../a/lib/lib.es2020.full.d.ts": { "version": "-7698705165-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }", "signature": "-7698705165-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }", - "affectsGlobalScope": true + "affectsGlobalScope": true, + "impliedFormat": 1 }, "../const.cts": { "version": "-11202312776-export type TheNum = 42;", @@ -456,7 +744,8 @@ exitCode:: ExitStatus.undefined }, "../index.cts": { "version": "-9668872159-export type { TheNum } from './const.cjs';", - "signature": "-9835135925-export type { TheNum } from './const.cjs';\n" + "signature": "-9835135925-export type { TheNum } from './const.cjs';\n", + "impliedFormat": 1 } }, "options": { @@ -481,7 +770,7 @@ exitCode:: ExitStatus.undefined ] }, "version": "FakeTSVersion", - "size": 892 + "size": 928 } //// [/user/username/projects/myproject/packages/pkg2/build/index.cjs] From b12315f05de78eb6b2bf8f46325933454ebdb02a Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Wed, 1 Sep 2021 11:12:33 -0700 Subject: [PATCH 6/9] Minor PR feedback --- src/compiler/commandLineParser.ts | 6 +++--- src/compiler/emitter.ts | 21 +++++---------------- src/compiler/program.ts | 2 +- src/compiler/utilities.ts | 10 +++++----- src/services/stringCompletions.ts | 2 +- 5 files changed, 15 insertions(+), 26 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 8762416d91d60..37f27b76a42e4 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -3201,7 +3201,7 @@ namespace ts { // Rather than re-query this for each file and filespec, we query the supported extensions // once and store it on the expansion context. const supportedExtensions = getSupportedExtensions(options, extraFileExtensions); - const supportedExtensionsWithJsonIfResolveJsonModule = getSuppoertedExtensionsWithJsonIfResolveJsonModule(options, supportedExtensions); + const supportedExtensionsWithJsonIfResolveJsonModule = getSupportedExtensionsWithJsonIfResolveJsonModule(options, supportedExtensions); // Literal files are always included verbatim. An "include" or "exclude" specification cannot // remove a literal file. @@ -3447,7 +3447,7 @@ namespace ts { } for (const ext of extensionGroup) { if (fileExtensionIs(file, ext)) { - break; + return false; } const higherPriorityPath = keyMapper(changeExtension(file, ext)); if (literalFiles.has(higherPriorityPath) || wildcardFiles.has(higherPriorityPath)) { @@ -3478,7 +3478,7 @@ namespace ts { for (let i = extensionGroup.length - 1; i >= 0; i--) { const ext = extensionGroup[i]; if (fileExtensionIs(file, ext)) { - break; + return; } const lowerPriorityPath = keyMapper(changeExtension(file, ext)); wildcardFiles.delete(lowerPriorityPath); diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 943dd14836e78..f8357b57394bd 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -108,22 +108,11 @@ namespace ts { /* @internal */ export function getOutputExtension(fileName: string, options: CompilerOptions): Extension { - if (fileExtensionIs(fileName, Extension.Json)) { - return Extension.Json; - } - - if (options.jsx === JsxEmit.Preserve) { - if (fileExtensionIsOneOf(fileName, [Extension.Jsx, Extension.Tsx])) { - return Extension.Jsx; - } - } - if (fileExtensionIsOneOf(fileName, [Extension.Mts, Extension.Mjs])) { - return Extension.Mjs; - } - if (fileExtensionIsOneOf(fileName, [Extension.Cts, Extension.Cjs])) { - return Extension.Cjs; - } - return Extension.Js; + return fileExtensionIs(fileName, Extension.Json) ? Extension.Json : + options.jsx === JsxEmit.Preserve && fileExtensionIsOneOf(fileName, [Extension.Jsx, Extension.Tsx]) ? Extension.Jsx : + fileExtensionIsOneOf(fileName, [Extension.Mts, Extension.Mjs]) ? Extension.Mjs : + fileExtensionIsOneOf(fileName, [Extension.Cts, Extension.Cjs]) ? Extension.Cjs : + Extension.Js; } function getOutputPathWithoutChangingExt(inputFileName: string, configFile: ParsedCommandLine, ignoreCase: boolean, outputDir: string | undefined, getCommonSourceDirectory?: () => string) { diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 2db7b08f86b20..17de23668d22d 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -883,7 +883,7 @@ namespace ts { const programDiagnostics = createDiagnosticCollection(); const currentDirectory = host.getCurrentDirectory(); const supportedExtensions = getSupportedExtensions(options); - const supportedExtensionsWithJsonIfResolveJsonModule = getSuppoertedExtensionsWithJsonIfResolveJsonModule(options, supportedExtensions); + const supportedExtensionsWithJsonIfResolveJsonModule = getSupportedExtensionsWithJsonIfResolveJsonModule(options, supportedExtensions); // Map storing if there is emit blocking diagnostics for given input const hasEmitBlockingDiagnostics = new Map(); diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index a700a98e5a4c1..627c0f8eb9b90 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -6738,7 +6738,7 @@ namespace ts { } /** - * List of supported extensions in order of file resolution precedence. + * Groups of supported extensions in order of file resolution precedence. (eg, TS > TSX > DTS and seperately, CTS > DCTS) */ export const supportedTSExtensions: readonly Extension[][] = [[Extension.Ts, Extension.Tsx, Extension.Dts], [Extension.Cts, Extension.Dcts], [Extension.Mts, Extension.Dmts]]; export const supportedTSExtensionsFlat: readonly Extension[] = flatten(supportedTSExtensions); @@ -6769,9 +6769,9 @@ namespace ts { return extensions; } - export function getSuppoertedExtensionsWithJsonIfResolveJsonModule(options: CompilerOptions | undefined, supportedExtensions: readonly Extension[][]): readonly Extension[][]; - export function getSuppoertedExtensionsWithJsonIfResolveJsonModule(options: CompilerOptions | undefined, supportedExtensions: readonly string[][]): readonly string[][]; - export function getSuppoertedExtensionsWithJsonIfResolveJsonModule(options: CompilerOptions | undefined, supportedExtensions: readonly string[][]): readonly string[][] { + export function getSupportedExtensionsWithJsonIfResolveJsonModule(options: CompilerOptions | undefined, supportedExtensions: readonly Extension[][]): readonly Extension[][]; + export function getSupportedExtensionsWithJsonIfResolveJsonModule(options: CompilerOptions | undefined, supportedExtensions: readonly string[][]): readonly string[][]; + export function getSupportedExtensionsWithJsonIfResolveJsonModule(options: CompilerOptions | undefined, supportedExtensions: readonly string[][]): readonly string[][] { if (!options || !options.resolveJsonModule) return supportedExtensions; if (supportedExtensions === allSupportedExtensions) return allSupportedExtensionsWithJson; if (supportedExtensions === supportedTSExtensions) return supportedTSExtensionsWithJson; @@ -6794,7 +6794,7 @@ namespace ts { if (!fileName) return false; const supportedExtensions = getSupportedExtensions(compilerOptions, extraFileExtensions); - for (const extension of flatten(getSuppoertedExtensionsWithJsonIfResolveJsonModule(compilerOptions, supportedExtensions))) { + for (const extension of flatten(getSupportedExtensionsWithJsonIfResolveJsonModule(compilerOptions, supportedExtensions))) { if (fileExtensionIs(fileName, extension)) { return true; } diff --git a/src/services/stringCompletions.ts b/src/services/stringCompletions.ts index f3c04d9ac8b82..cc81c6ab97f0e 100644 --- a/src/services/stringCompletions.ts +++ b/src/services/stringCompletions.ts @@ -347,7 +347,7 @@ namespace ts.Completions.StringCompletions { function getSupportedExtensionsForModuleResolution(compilerOptions: CompilerOptions): readonly Extension[][] { const extensions = getSupportedExtensions(compilerOptions); return getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.NodeJs ? - getSuppoertedExtensionsWithJsonIfResolveJsonModule(compilerOptions, extensions) : + getSupportedExtensionsWithJsonIfResolveJsonModule(compilerOptions, extensions) : extensions; } From 15e1904fd7343a28486785ef63768d1f967c008a Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Wed, 1 Sep 2021 11:22:40 -0700 Subject: [PATCH 7/9] Adjust error message --- src/compiler/checker.ts | 4 +- src/compiler/diagnosticMessages.json | 4 +- ...esForbidenSyntax(module=node12).errors.txt | 96 +++++++++---------- ...ForbidenSyntax(module=nodenext).errors.txt | 96 +++++++++---------- 4 files changed, 100 insertions(+), 100 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 1fc9416faf634..44e02840e046b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -30560,7 +30560,7 @@ namespace ts { if (node.kind === SyntaxKind.TypeAssertionExpression) { const file = getSourceFileOfNode(node); if (file && fileExtensionIsOneOf(file.fileName, [Extension.Cts, Extension.Mts])) { - grammarErrorOnNode(node, Diagnostics.This_syntax_is_reserved_in_files_with_this_extension_Use_an_as_expression_instead); + grammarErrorOnNode(node, Diagnostics.This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Use_an_as_expression_instead); } } return checkAssertionWorker(node, node.type, node.expression); @@ -41806,7 +41806,7 @@ namespace ts { if (node.typeParameters && !(length(node.typeParameters) > 1 || node.typeParameters.hasTrailingComma || node.typeParameters[0].constraint)) { if (file && fileExtensionIsOneOf(file.fileName, [Extension.Mts, Extension.Cts])) { - grammarErrorOnNode(node.typeParameters[0], Diagnostics.This_syntax_is_reserved_in_files_with_this_extension_Add_a_trailing_comma_or_explicit_constraint); + grammarErrorOnNode(node.typeParameters[0], Diagnostics.This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Add_a_trailing_comma_or_explicit_constraint); } } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index ca529d2e29539..66da25d3ec66a 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -5888,11 +5888,11 @@ "category": "Error", "code": 7058 }, - "This syntax is reserved in files with this extension. Use an `as` expression instead.": { + "This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead.": { "category": "Error", "code": 7059 }, - "This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint.": { + "This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint.": { "category": "Error", "code": 7060 }, diff --git a/tests/baselines/reference/nodeModulesForbidenSyntax(module=node12).errors.txt b/tests/baselines/reference/nodeModulesForbidenSyntax(module=node12).errors.txt index cf09fc77b2f5a..984483a332e29 100644 --- a/tests/baselines/reference/nodeModulesForbidenSyntax(module=node12).errors.txt +++ b/tests/baselines/reference/nodeModulesForbidenSyntax(module=node12).errors.txt @@ -1,27 +1,27 @@ -tests/cases/conformance/node/index.cts(2,12): error TS7060: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. -tests/cases/conformance/node/index.cts(2,20): error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. -tests/cases/conformance/node/index.cts(2,23): error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. -tests/cases/conformance/node/index.mts(2,12): error TS7060: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. -tests/cases/conformance/node/index.mts(2,20): error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. -tests/cases/conformance/node/index.mts(2,23): error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. -tests/cases/conformance/node/subfolder/index.cts(2,12): error TS7060: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. -tests/cases/conformance/node/subfolder/index.cts(2,20): error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. -tests/cases/conformance/node/subfolder/index.cts(2,23): error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. -tests/cases/conformance/node/subfolder/index.mts(2,12): error TS7060: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. -tests/cases/conformance/node/subfolder/index.mts(2,20): error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. -tests/cases/conformance/node/subfolder/index.mts(2,23): error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. -tests/cases/conformance/node/subfolder2/another/index.cts(2,12): error TS7060: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. -tests/cases/conformance/node/subfolder2/another/index.cts(2,20): error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. -tests/cases/conformance/node/subfolder2/another/index.cts(2,23): error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. -tests/cases/conformance/node/subfolder2/another/index.mts(2,12): error TS7060: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. -tests/cases/conformance/node/subfolder2/another/index.mts(2,20): error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. -tests/cases/conformance/node/subfolder2/another/index.mts(2,23): error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. -tests/cases/conformance/node/subfolder2/index.cts(2,12): error TS7060: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. -tests/cases/conformance/node/subfolder2/index.cts(2,20): error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. -tests/cases/conformance/node/subfolder2/index.cts(2,23): error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. -tests/cases/conformance/node/subfolder2/index.mts(2,12): error TS7060: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. -tests/cases/conformance/node/subfolder2/index.mts(2,20): error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. -tests/cases/conformance/node/subfolder2/index.mts(2,23): error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. +tests/cases/conformance/node/index.cts(2,12): error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint. +tests/cases/conformance/node/index.cts(2,20): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. +tests/cases/conformance/node/index.cts(2,23): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. +tests/cases/conformance/node/index.mts(2,12): error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint. +tests/cases/conformance/node/index.mts(2,20): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. +tests/cases/conformance/node/index.mts(2,23): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder/index.cts(2,12): error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint. +tests/cases/conformance/node/subfolder/index.cts(2,20): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder/index.cts(2,23): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder/index.mts(2,12): error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint. +tests/cases/conformance/node/subfolder/index.mts(2,20): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder/index.mts(2,23): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder2/another/index.cts(2,12): error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint. +tests/cases/conformance/node/subfolder2/another/index.cts(2,20): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder2/another/index.cts(2,23): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder2/another/index.mts(2,12): error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint. +tests/cases/conformance/node/subfolder2/another/index.mts(2,20): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder2/another/index.mts(2,23): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder2/index.cts(2,12): error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint. +tests/cases/conformance/node/subfolder2/index.cts(2,20): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder2/index.cts(2,23): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder2/index.mts(2,12): error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint. +tests/cases/conformance/node/subfolder2/index.mts(2,20): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder2/index.mts(2,23): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. ==== tests/cases/conformance/node/subfolder/index.ts (0 errors) ==== @@ -32,21 +32,21 @@ tests/cases/conformance/node/subfolder2/index.mts(2,23): error TS7059: This synt // cjs format file const x = () => (void 0); ~ -!!! error TS7060: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. +!!! error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint. ~~~~~~~~~~~~~~~~ -!!! error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. +!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. ~~~~~~~~~~~~~ -!!! error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. +!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. export {x}; ==== tests/cases/conformance/node/subfolder/index.mts (3 errors) ==== // esm format file const x = () => (void 0); ~ -!!! error TS7060: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. +!!! error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint. ~~~~~~~~~~~~~~~~ -!!! error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. +!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. ~~~~~~~~~~~~~ -!!! error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. +!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. export {x}; ==== tests/cases/conformance/node/subfolder2/index.ts (0 errors) ==== // cjs format file @@ -56,21 +56,21 @@ tests/cases/conformance/node/subfolder2/index.mts(2,23): error TS7059: This synt // cjs format file const x = () => (void 0); ~ -!!! error TS7060: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. +!!! error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint. ~~~~~~~~~~~~~~~~ -!!! error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. +!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. ~~~~~~~~~~~~~ -!!! error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. +!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. export {x}; ==== tests/cases/conformance/node/subfolder2/index.mts (3 errors) ==== // esm format file const x = () => (void 0); ~ -!!! error TS7060: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. +!!! error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint. ~~~~~~~~~~~~~~~~ -!!! error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. +!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. ~~~~~~~~~~~~~ -!!! error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. +!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. export {x}; ==== tests/cases/conformance/node/subfolder2/another/index.ts (0 errors) ==== // esm format file @@ -80,41 +80,41 @@ tests/cases/conformance/node/subfolder2/index.mts(2,23): error TS7059: This synt // esm format file const x = () => (void 0); ~ -!!! error TS7060: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. +!!! error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint. ~~~~~~~~~~~~~~~~ -!!! error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. +!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. ~~~~~~~~~~~~~ -!!! error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. +!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. export {x}; ==== tests/cases/conformance/node/subfolder2/another/index.cts (3 errors) ==== // cjs format file const x = () => (void 0); ~ -!!! error TS7060: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. +!!! error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint. ~~~~~~~~~~~~~~~~ -!!! error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. +!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. ~~~~~~~~~~~~~ -!!! error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. +!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. export {x}; ==== tests/cases/conformance/node/index.mts (3 errors) ==== // esm format file const x = () => (void 0); ~ -!!! error TS7060: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. +!!! error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint. ~~~~~~~~~~~~~~~~ -!!! error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. +!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. ~~~~~~~~~~~~~ -!!! error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. +!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. export {x}; ==== tests/cases/conformance/node/index.cts (3 errors) ==== // cjs format file const x = () => (void 0); ~ -!!! error TS7060: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. +!!! error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint. ~~~~~~~~~~~~~~~~ -!!! error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. +!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. ~~~~~~~~~~~~~ -!!! error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. +!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. export {x}; ==== tests/cases/conformance/node/index.ts (0 errors) ==== // esm format file diff --git a/tests/baselines/reference/nodeModulesForbidenSyntax(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesForbidenSyntax(module=nodenext).errors.txt index cf09fc77b2f5a..984483a332e29 100644 --- a/tests/baselines/reference/nodeModulesForbidenSyntax(module=nodenext).errors.txt +++ b/tests/baselines/reference/nodeModulesForbidenSyntax(module=nodenext).errors.txt @@ -1,27 +1,27 @@ -tests/cases/conformance/node/index.cts(2,12): error TS7060: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. -tests/cases/conformance/node/index.cts(2,20): error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. -tests/cases/conformance/node/index.cts(2,23): error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. -tests/cases/conformance/node/index.mts(2,12): error TS7060: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. -tests/cases/conformance/node/index.mts(2,20): error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. -tests/cases/conformance/node/index.mts(2,23): error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. -tests/cases/conformance/node/subfolder/index.cts(2,12): error TS7060: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. -tests/cases/conformance/node/subfolder/index.cts(2,20): error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. -tests/cases/conformance/node/subfolder/index.cts(2,23): error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. -tests/cases/conformance/node/subfolder/index.mts(2,12): error TS7060: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. -tests/cases/conformance/node/subfolder/index.mts(2,20): error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. -tests/cases/conformance/node/subfolder/index.mts(2,23): error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. -tests/cases/conformance/node/subfolder2/another/index.cts(2,12): error TS7060: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. -tests/cases/conformance/node/subfolder2/another/index.cts(2,20): error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. -tests/cases/conformance/node/subfolder2/another/index.cts(2,23): error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. -tests/cases/conformance/node/subfolder2/another/index.mts(2,12): error TS7060: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. -tests/cases/conformance/node/subfolder2/another/index.mts(2,20): error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. -tests/cases/conformance/node/subfolder2/another/index.mts(2,23): error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. -tests/cases/conformance/node/subfolder2/index.cts(2,12): error TS7060: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. -tests/cases/conformance/node/subfolder2/index.cts(2,20): error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. -tests/cases/conformance/node/subfolder2/index.cts(2,23): error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. -tests/cases/conformance/node/subfolder2/index.mts(2,12): error TS7060: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. -tests/cases/conformance/node/subfolder2/index.mts(2,20): error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. -tests/cases/conformance/node/subfolder2/index.mts(2,23): error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. +tests/cases/conformance/node/index.cts(2,12): error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint. +tests/cases/conformance/node/index.cts(2,20): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. +tests/cases/conformance/node/index.cts(2,23): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. +tests/cases/conformance/node/index.mts(2,12): error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint. +tests/cases/conformance/node/index.mts(2,20): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. +tests/cases/conformance/node/index.mts(2,23): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder/index.cts(2,12): error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint. +tests/cases/conformance/node/subfolder/index.cts(2,20): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder/index.cts(2,23): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder/index.mts(2,12): error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint. +tests/cases/conformance/node/subfolder/index.mts(2,20): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder/index.mts(2,23): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder2/another/index.cts(2,12): error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint. +tests/cases/conformance/node/subfolder2/another/index.cts(2,20): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder2/another/index.cts(2,23): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder2/another/index.mts(2,12): error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint. +tests/cases/conformance/node/subfolder2/another/index.mts(2,20): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder2/another/index.mts(2,23): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder2/index.cts(2,12): error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint. +tests/cases/conformance/node/subfolder2/index.cts(2,20): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder2/index.cts(2,23): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder2/index.mts(2,12): error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint. +tests/cases/conformance/node/subfolder2/index.mts(2,20): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. +tests/cases/conformance/node/subfolder2/index.mts(2,23): error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. ==== tests/cases/conformance/node/subfolder/index.ts (0 errors) ==== @@ -32,21 +32,21 @@ tests/cases/conformance/node/subfolder2/index.mts(2,23): error TS7059: This synt // cjs format file const x = () => (void 0); ~ -!!! error TS7060: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. +!!! error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint. ~~~~~~~~~~~~~~~~ -!!! error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. +!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. ~~~~~~~~~~~~~ -!!! error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. +!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. export {x}; ==== tests/cases/conformance/node/subfolder/index.mts (3 errors) ==== // esm format file const x = () => (void 0); ~ -!!! error TS7060: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. +!!! error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint. ~~~~~~~~~~~~~~~~ -!!! error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. +!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. ~~~~~~~~~~~~~ -!!! error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. +!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. export {x}; ==== tests/cases/conformance/node/subfolder2/index.ts (0 errors) ==== // cjs format file @@ -56,21 +56,21 @@ tests/cases/conformance/node/subfolder2/index.mts(2,23): error TS7059: This synt // cjs format file const x = () => (void 0); ~ -!!! error TS7060: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. +!!! error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint. ~~~~~~~~~~~~~~~~ -!!! error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. +!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. ~~~~~~~~~~~~~ -!!! error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. +!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. export {x}; ==== tests/cases/conformance/node/subfolder2/index.mts (3 errors) ==== // esm format file const x = () => (void 0); ~ -!!! error TS7060: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. +!!! error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint. ~~~~~~~~~~~~~~~~ -!!! error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. +!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. ~~~~~~~~~~~~~ -!!! error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. +!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. export {x}; ==== tests/cases/conformance/node/subfolder2/another/index.ts (0 errors) ==== // esm format file @@ -80,41 +80,41 @@ tests/cases/conformance/node/subfolder2/index.mts(2,23): error TS7059: This synt // esm format file const x = () => (void 0); ~ -!!! error TS7060: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. +!!! error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint. ~~~~~~~~~~~~~~~~ -!!! error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. +!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. ~~~~~~~~~~~~~ -!!! error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. +!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. export {x}; ==== tests/cases/conformance/node/subfolder2/another/index.cts (3 errors) ==== // cjs format file const x = () => (void 0); ~ -!!! error TS7060: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. +!!! error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint. ~~~~~~~~~~~~~~~~ -!!! error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. +!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. ~~~~~~~~~~~~~ -!!! error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. +!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. export {x}; ==== tests/cases/conformance/node/index.mts (3 errors) ==== // esm format file const x = () => (void 0); ~ -!!! error TS7060: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. +!!! error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint. ~~~~~~~~~~~~~~~~ -!!! error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. +!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. ~~~~~~~~~~~~~ -!!! error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. +!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. export {x}; ==== tests/cases/conformance/node/index.cts (3 errors) ==== // cjs format file const x = () => (void 0); ~ -!!! error TS7060: This syntax is reserved in files with this extension. Add a trailing comma or explicit constraint. +!!! error TS7060: This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint. ~~~~~~~~~~~~~~~~ -!!! error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. +!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. ~~~~~~~~~~~~~ -!!! error TS7059: This syntax is reserved in files with this extension. Use an `as` expression instead. +!!! error TS7059: This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead. export {x}; ==== tests/cases/conformance/node/index.ts (0 errors) ==== // esm format file From 5bf44ac87b3e6998cf6e5c6dc0c9637a9d4c4ea7 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 14 Sep 2021 19:38:07 -0700 Subject: [PATCH 8/9] Accept new error codes --- .../nodeModules1(module=node12).errors.txt | 24 +++++++++---------- .../nodeModules1(module=nodenext).errors.txt | 24 +++++++++---------- ...eModulesAllowJs1(module=node12).errors.txt | 24 +++++++++---------- ...odulesAllowJs1(module=nodenext).errors.txt | 24 +++++++++---------- ...t-correctly-with-cts-and-mts-extensions.js | 4 ++-- 5 files changed, 50 insertions(+), 50 deletions(-) diff --git a/tests/baselines/reference/nodeModules1(module=node12).errors.txt b/tests/baselines/reference/nodeModules1(module=node12).errors.txt index 72fc62c6aed5f..a2f68a704a96f 100644 --- a/tests/baselines/reference/nodeModules1(module=node12).errors.txt +++ b/tests/baselines/reference/nodeModules1(module=node12).errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/node/index.cts(2,21): error TS1445: Module './index.js' 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/index.cts(3,21): error TS1445: Module './index.mjs' 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/index.cts(6,21): error TS1445: Module './subfolder/index.mjs' 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/index.cts(9,21): error TS1445: Module './subfolder2/index.mjs' 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/index.cts(11,22): error TS1445: Module './subfolder2/another/index.js' 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/index.cts(12,22): error TS1445: Module './subfolder2/another/index.mjs' 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/index.cts(2,21): error TS1471: Module './index.js' 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/index.cts(3,21): error TS1471: Module './index.mjs' 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/index.cts(6,21): error TS1471: Module './subfolder/index.mjs' 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/index.cts(9,21): error TS1471: Module './subfolder2/index.mjs' 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/index.cts(11,22): error TS1471: Module './subfolder2/another/index.js' 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/index.cts(12,22): error TS1471: Module './subfolder2/another/index.mjs' 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/subfolder/index.ts (0 errors) ==== @@ -74,27 +74,27 @@ tests/cases/conformance/node/index.cts(12,22): error TS1445: Module './subfolder // ESM-format imports below should issue errors import * as m1 from "./index.js"; ~~~~~~~~~~~~ -!!! error TS1445: Module './index.js' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. import * as m2 from "./index.mjs"; ~~~~~~~~~~~~~ -!!! error TS1445: Module './index.mjs' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './index.mjs' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. import * as m3 from "./index.cjs"; import * as m4 from "./subfolder/index.js"; import * as m5 from "./subfolder/index.mjs"; ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1445: Module './subfolder/index.mjs' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './subfolder/index.mjs' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. import * as m6 from "./subfolder/index.cjs"; import * as m7 from "./subfolder2/index.js"; import * as m8 from "./subfolder2/index.mjs"; ~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1445: Module './subfolder2/index.mjs' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './subfolder2/index.mjs' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. import * as m9 from "./subfolder2/index.cjs"; import * as m10 from "./subfolder2/another/index.js"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1445: Module './subfolder2/another/index.js' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './subfolder2/another/index.js' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. import * as m11 from "./subfolder2/another/index.mjs"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1445: Module './subfolder2/another/index.mjs' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './subfolder2/another/index.mjs' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. import * as m12 from "./subfolder2/another/index.cjs"; void m1; void m2; diff --git a/tests/baselines/reference/nodeModules1(module=nodenext).errors.txt b/tests/baselines/reference/nodeModules1(module=nodenext).errors.txt index 72fc62c6aed5f..a2f68a704a96f 100644 --- a/tests/baselines/reference/nodeModules1(module=nodenext).errors.txt +++ b/tests/baselines/reference/nodeModules1(module=nodenext).errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/node/index.cts(2,21): error TS1445: Module './index.js' 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/index.cts(3,21): error TS1445: Module './index.mjs' 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/index.cts(6,21): error TS1445: Module './subfolder/index.mjs' 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/index.cts(9,21): error TS1445: Module './subfolder2/index.mjs' 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/index.cts(11,22): error TS1445: Module './subfolder2/another/index.js' 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/index.cts(12,22): error TS1445: Module './subfolder2/another/index.mjs' 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/index.cts(2,21): error TS1471: Module './index.js' 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/index.cts(3,21): error TS1471: Module './index.mjs' 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/index.cts(6,21): error TS1471: Module './subfolder/index.mjs' 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/index.cts(9,21): error TS1471: Module './subfolder2/index.mjs' 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/index.cts(11,22): error TS1471: Module './subfolder2/another/index.js' 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/index.cts(12,22): error TS1471: Module './subfolder2/another/index.mjs' 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/subfolder/index.ts (0 errors) ==== @@ -74,27 +74,27 @@ tests/cases/conformance/node/index.cts(12,22): error TS1445: Module './subfolder // ESM-format imports below should issue errors import * as m1 from "./index.js"; ~~~~~~~~~~~~ -!!! error TS1445: Module './index.js' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. import * as m2 from "./index.mjs"; ~~~~~~~~~~~~~ -!!! error TS1445: Module './index.mjs' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './index.mjs' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. import * as m3 from "./index.cjs"; import * as m4 from "./subfolder/index.js"; import * as m5 from "./subfolder/index.mjs"; ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1445: Module './subfolder/index.mjs' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './subfolder/index.mjs' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. import * as m6 from "./subfolder/index.cjs"; import * as m7 from "./subfolder2/index.js"; import * as m8 from "./subfolder2/index.mjs"; ~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1445: Module './subfolder2/index.mjs' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './subfolder2/index.mjs' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. import * as m9 from "./subfolder2/index.cjs"; import * as m10 from "./subfolder2/another/index.js"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1445: Module './subfolder2/another/index.js' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './subfolder2/another/index.js' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. import * as m11 from "./subfolder2/another/index.mjs"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1445: Module './subfolder2/another/index.mjs' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './subfolder2/another/index.mjs' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. import * as m12 from "./subfolder2/another/index.cjs"; void m1; void m2; diff --git a/tests/baselines/reference/nodeModulesAllowJs1(module=node12).errors.txt b/tests/baselines/reference/nodeModulesAllowJs1(module=node12).errors.txt index 41443989a961d..365b00a0e162f 100644 --- a/tests/baselines/reference/nodeModulesAllowJs1(module=node12).errors.txt +++ b/tests/baselines/reference/nodeModulesAllowJs1(module=node12).errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/node/allowJs/index.cjs(2,21): error TS1445: Module './index.js' 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(3,21): error TS1445: Module './index.mjs' 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(6,21): error TS1445: Module './subfolder/index.mjs' 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(9,21): error TS1445: Module './subfolder2/index.mjs' 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(11,22): error TS1445: Module './subfolder2/another/index.js' 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(12,22): error TS1445: Module './subfolder2/another/index.mjs' 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(2,21): error TS1471: Module './index.js' 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(3,21): error TS1471: Module './index.mjs' 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(6,21): error TS1471: Module './subfolder/index.mjs' 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(9,21): error TS1471: Module './subfolder2/index.mjs' 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(11,22): error TS1471: Module './subfolder2/another/index.js' 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(12,22): error TS1471: Module './subfolder2/another/index.mjs' 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/subfolder/index.js (0 errors) ==== @@ -74,27 +74,27 @@ tests/cases/conformance/node/allowJs/index.cjs(12,22): error TS1445: Module './s // ESM format imports below should error import * as m1 from "./index.js"; ~~~~~~~~~~~~ -!!! error TS1445: Module './index.js' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. import * as m2 from "./index.mjs"; ~~~~~~~~~~~~~ -!!! error TS1445: Module './index.mjs' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './index.mjs' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. import * as m3 from "./index.cjs"; import * as m4 from "./subfolder/index.js"; import * as m5 from "./subfolder/index.mjs"; ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1445: Module './subfolder/index.mjs' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './subfolder/index.mjs' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. import * as m6 from "./subfolder/index.cjs"; import * as m7 from "./subfolder2/index.js"; import * as m8 from "./subfolder2/index.mjs"; ~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1445: Module './subfolder2/index.mjs' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './subfolder2/index.mjs' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. import * as m9 from "./subfolder2/index.cjs"; import * as m10 from "./subfolder2/another/index.js"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1445: Module './subfolder2/another/index.js' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './subfolder2/another/index.js' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. import * as m11 from "./subfolder2/another/index.mjs"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1445: Module './subfolder2/another/index.mjs' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './subfolder2/another/index.mjs' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. import * as m12 from "./subfolder2/another/index.cjs"; void m1; void m2; diff --git a/tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).errors.txt b/tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).errors.txt index 41443989a961d..365b00a0e162f 100644 --- a/tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).errors.txt +++ b/tests/baselines/reference/nodeModulesAllowJs1(module=nodenext).errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/node/allowJs/index.cjs(2,21): error TS1445: Module './index.js' 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(3,21): error TS1445: Module './index.mjs' 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(6,21): error TS1445: Module './subfolder/index.mjs' 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(9,21): error TS1445: Module './subfolder2/index.mjs' 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(11,22): error TS1445: Module './subfolder2/another/index.js' 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(12,22): error TS1445: Module './subfolder2/another/index.mjs' 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(2,21): error TS1471: Module './index.js' 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(3,21): error TS1471: Module './index.mjs' 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(6,21): error TS1471: Module './subfolder/index.mjs' 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(9,21): error TS1471: Module './subfolder2/index.mjs' 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(11,22): error TS1471: Module './subfolder2/another/index.js' 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(12,22): error TS1471: Module './subfolder2/another/index.mjs' 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/subfolder/index.js (0 errors) ==== @@ -74,27 +74,27 @@ tests/cases/conformance/node/allowJs/index.cjs(12,22): error TS1445: Module './s // ESM format imports below should error import * as m1 from "./index.js"; ~~~~~~~~~~~~ -!!! error TS1445: Module './index.js' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './index.js' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. import * as m2 from "./index.mjs"; ~~~~~~~~~~~~~ -!!! error TS1445: Module './index.mjs' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './index.mjs' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. import * as m3 from "./index.cjs"; import * as m4 from "./subfolder/index.js"; import * as m5 from "./subfolder/index.mjs"; ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1445: Module './subfolder/index.mjs' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './subfolder/index.mjs' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. import * as m6 from "./subfolder/index.cjs"; import * as m7 from "./subfolder2/index.js"; import * as m8 from "./subfolder2/index.mjs"; ~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1445: Module './subfolder2/index.mjs' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './subfolder2/index.mjs' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. import * as m9 from "./subfolder2/index.cjs"; import * as m10 from "./subfolder2/another/index.js"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1445: Module './subfolder2/another/index.js' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './subfolder2/another/index.js' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. import * as m11 from "./subfolder2/another/index.mjs"; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1445: Module './subfolder2/another/index.mjs' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. +!!! error TS1471: Module './subfolder2/another/index.mjs' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. import * as m12 from "./subfolder2/another/index.cjs"; void m1; void m2; diff --git a/tests/baselines/reference/tsbuild/watchMode/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-cts-and-mts-extensions.js b/tests/baselines/reference/tsbuild/watchMode/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-cts-and-mts-extensions.js index 1a445f232047e..6a2a409b814cf 100644 --- a/tests/baselines/reference/tsbuild/watchMode/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-cts-and-mts-extensions.js +++ b/tests/baselines/reference/tsbuild/watchMode/moduleResolution/resolves-specifier-in-output-declaration-file-from-referenced-project-correctly-with-cts-and-mts-extensions.js @@ -326,7 +326,7 @@ File '/user/username/projects/myproject/packages/pkg2/build/const.d.cts' exist - File '/a/lib/package.json' does not exist. File '/a/package.json' does not exist. File '/package.json' does not exist. -packages/pkg1/index.ts:1:29 - error TS1445: Module 'pkg2' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. +packages/pkg1/index.ts:1:29 - error TS1471: Module 'pkg2' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. 1 import type { TheNum } from 'pkg2'    ~~~~~~ @@ -564,7 +564,7 @@ File '/user/username/projects/myproject/packages/pkg2/build/const.d.cts' exist - File '/a/lib/package.json' does not exist. File '/a/package.json' does not exist. File '/package.json' does not exist. -packages/pkg1/index.ts:1:29 - error TS1445: Module 'pkg2' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. +packages/pkg1/index.ts:1:29 - error TS1471: Module 'pkg2' cannot be imported using this construct. The specifier only resolves to an es module, which cannot be imported synchronously. Use dynamic import instead. 1 import type { TheNum } from 'pkg2'    ~~~~~~ From 21b73e82ef8b1b07086e415b195b5f707a6d557b Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Mon, 20 Sep 2021 19:09:36 -0700 Subject: [PATCH 9/9] Accept updated baseline --- ...importAssertion1(module=es2015).errors.txt | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/tests/baselines/reference/importAssertion1(module=es2015).errors.txt b/tests/baselines/reference/importAssertion1(module=es2015).errors.txt index f9603006232bb..12775e5e5807b 100644 --- a/tests/baselines/reference/importAssertion1(module=es2015).errors.txt +++ b/tests/baselines/reference/importAssertion1(module=es2015).errors.txt @@ -3,15 +3,15 @@ tests/cases/conformance/importAssertion/1.ts(2,28): error TS2821: Import asserti tests/cases/conformance/importAssertion/1.ts(3,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext'. tests/cases/conformance/importAssertion/2.ts(1,28): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext'. tests/cases/conformance/importAssertion/2.ts(2,38): error TS2821: Import assertions are only supported when the '--module' option is set to 'esnext'. -tests/cases/conformance/importAssertion/3.ts(1,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'. -tests/cases/conformance/importAssertion/3.ts(2,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'. -tests/cases/conformance/importAssertion/3.ts(3,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'. -tests/cases/conformance/importAssertion/3.ts(4,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'. -tests/cases/conformance/importAssertion/3.ts(5,12): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'. -tests/cases/conformance/importAssertion/3.ts(7,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'. -tests/cases/conformance/importAssertion/3.ts(8,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'. -tests/cases/conformance/importAssertion/3.ts(9,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'. -tests/cases/conformance/importAssertion/3.ts(10,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'. +tests/cases/conformance/importAssertion/3.ts(1,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. +tests/cases/conformance/importAssertion/3.ts(2,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. +tests/cases/conformance/importAssertion/3.ts(3,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. +tests/cases/conformance/importAssertion/3.ts(4,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. +tests/cases/conformance/importAssertion/3.ts(5,12): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. +tests/cases/conformance/importAssertion/3.ts(7,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. +tests/cases/conformance/importAssertion/3.ts(8,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. +tests/cases/conformance/importAssertion/3.ts(9,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. +tests/cases/conformance/importAssertion/3.ts(10,11): error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. ==== tests/cases/conformance/importAssertion/0.ts (0 errors) ==== @@ -48,31 +48,31 @@ tests/cases/conformance/importAssertion/3.ts(10,11): error TS1323: Dynamic impor ==== tests/cases/conformance/importAssertion/3.ts (9 errors) ==== const a = import('./0') ~~~~~~~~~~~~~ -!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'. +!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. const b = import('./0', { assert: { type: "json" } }) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'. +!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. const c = import('./0', { assert: { type: "json", ttype: "typo" } }) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'. +!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. const d = import('./0', { assert: {} }) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'. +!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. const dd = import('./0', {}) ~~~~~~~~~~~~~~~~~ -!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'. +!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. declare function foo(): any; const e = import('./0', foo()) ~~~~~~~~~~~~~~~~~~~~ -!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'. +!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. const f = import() ~~~~~~~~ -!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'. +!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. const g = import('./0', {}, {}) ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'. +!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. const h = import('./0', { assert: { type: "json" }},) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', or 'umd'. +!!! error TS1323: Dynamic imports are only supported when the '--module' flag is set to 'es2020', 'esnext', 'commonjs', 'amd', 'system', 'umd', 'node12', or 'nodenext'. \ No newline at end of file