GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Start Node ESM stable version at Node16 by DanielRosenwasser · Pull Request #48879 · microsoft/TypeScript

Conversation

@DanielRosenwasser

@DanielRosenwasser Daniel Rosenwasser (DanielRosenwasser) commented Apr 28, 2022

Copy link
Copy Markdown
Member

Today Node 16 provides two really nice characteristics:

  • It supports all the resolution modes of Node 12 and Node 14 (a difference which won't be fixed)
  • It supports ES2022 features, including top-level await, ??=, #private fields, numeric separators, error causes, and more. This is nice because even if you're not transforming your input code, you won't get an error for using some of these constructs.

This PR starts our minimum stable version of Node targeting and resolution to Node 16 instead of Node 12.

There is a caveat which Wesley Wigham (@weswigham) pointed out, which is that top-level await isn't yet documented as stable.

Fixes #48646

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

shrujalshah28 and Jack-Works reacted with thumbs up emoji
All reactions
  • 👍 2 reactions
@DanielRosenwasser
Remove Node12, add Node16.
c0f2882
@DanielRosenwasser
Daniel Rosenwasser (DanielRosenwasser) requested review from Anders Hejlsberg (ahejlsberg), Andrew Branch (andrewbranch) and Wesley Wigham (weswigham) April 28, 2022 20:00
@typescript-bot TypeScript Bot (typescript-bot) assigned Daniel Rosenwasser (DanielRosenwasser) Apr 28, 2022
@typescript-bot TypeScript Bot (typescript-bot) added Author: Team For Milestone Bug PRs that fix a bug with a specific milestone labels Apr 28, 2022
@ghost

Deleted user (ghost) commented Apr 28, 2022

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission, we really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.

❌ DanielRosenwasser sign now
You have signed the CLA already but the status is still pending? Let us recheck it.

DanielRosenwasser and chriskrycho reacted with confused emoji
All reactions
  • 😕 2 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

DanielRosenwasser
Daniel Rosenwasser (DanielRosenwasser) commented Apr 28, 2022
View reviewed changes
Comment thread src/compiler/checker.ts Outdated
diagnostics.add(diagnostic);
}
if ((moduleKind !== ModuleKind.ES2022 && moduleKind !== ModuleKind.ESNext && moduleKind !== ModuleKind.System && !(moduleKind === ModuleKind.NodeNext && getSourceFileOfNode(node).impliedNodeFormat === ModuleKind.ESNext)) || languageVersion < ScriptTarget.ES2017) {
if ((moduleKind !== ModuleKind.ES2022 && moduleKind !== ModuleKind.ESNext && moduleKind !== ModuleKind.System && !(moduleKind >= ModuleKind.Node16 && getSourceFileOfNode(node).impliedNodeFormat === ModuleKind.ESNext)) || languageVersion < ScriptTarget.ES2017) {

@DanielRosenwasser Daniel Rosenwasser (DanielRosenwasser) Apr 28, 2022

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, this check is wrong and the tests reflect that. Should it be

Suggested change
if ((moduleKind !== ModuleKind.ES2022 && moduleKind !== ModuleKind.ESNext && moduleKind !== ModuleKind.System && !(moduleKind >= ModuleKind.Node16 && getSourceFileOfNode(node).impliedNodeFormat === ModuleKind.ESNext)) || languageVersion < ScriptTarget.ES2017) {
if ((moduleKind !== ModuleKind.ES2022 && moduleKind !== ModuleKind.ESNext && moduleKind !== ModuleKind.System && !(moduleKind < ModuleKind.Node16 && getSourceFileOfNode(node).impliedNodeFormat === ModuleKind.ESNext)) || languageVersion < ScriptTarget.ES2017) {

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@weswigham Wesley Wigham (weswigham) Apr 28, 2022

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normally we still emit warnings of some kind when using experimental features, which would still be in all stable versions of node, at least until nodejs/node#42875 ships in the next version of node 18.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@DanielRosenwasser Daniel Rosenwasser (DanielRosenwasser) Apr 28, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So maybe until TLA becomes non-experimental we could issue an error like

Top-level 'await' is currently experimental in Node.js. It can only be enabled when the 'module' option is set to 'nodenext'.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

weswigham reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@weswigham Wesley Wigham (weswigham) Apr 28, 2022

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On a related note, we should probably remove the experimental warning for json imports in nodenext. Afaik, they've stabilized in node 18. At least the version with the import assertion, anyway. It's contentious among the node maintainers.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@DanielRosenwasser Daniel Rosenwasser (DanielRosenwasser) Apr 29, 2022

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR is already merged - that seems like a pretty strong sign that it will be stable, right?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@DanielRosenwasser Daniel Rosenwasser (DanielRosenwasser) Apr 29, 2022

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test wasn't wrong, it was just very confusing because the code was in a CJS file. I've updated the check there.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@weswigham Wesley Wigham (weswigham) Apr 29, 2022

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it'll be stable in the next release of node 18, it just hasn't shipped yet, and I don't know if it'll be backported to 16 or not.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@andrewbranch Andrew Branch (andrewbranch) May 2, 2022

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At what point do they stop backporting features like that? Maintenance LTS? Is it practical to not create a named moduleResolution target until it solidifies?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@weswigham Wesley Wigham (weswigham) May 3, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes are backported to LTS versions unless they're somehow breaking from what I understand, while maintenance LTS versions only get security patches. At least I think that's the general policy. (The definition of "breaking" being the somewhat subjective part)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
DanielRosenwasser
Daniel Rosenwasser (DanielRosenwasser) commented Apr 28, 2022
View reviewed changes
Comment thread src/compiler/checker.ts Resolved

Uh oh!

There was an error while loading. Please reload this page.

@DanielRosenwasser
Accepted baselines.
52d1ea5
@DanielRosenwasser
Daniel Rosenwasser (DanielRosenwasser) force-pushed the toNode16 branch from bdf9922 to 52d1ea5 Compare April 28, 2022 20:28
Daniel Rosenwasser (DanielRosenwasser) added 2 commits April 29, 2022 01:04
@DanielRosenwasser
Refactor checking for top-level await, give a better error message in…
1247217
… CJS files.
@DanielRosenwasser
Accepted baselines.
c390b79
@DanielRosenwasser

Daniel Rosenwasser (DanielRosenwasser) commented Apr 29, 2022

Copy link
Copy Markdown
Member Author

Newest updates give a better error message when you have TLA in a CJS module.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Daniel Rosenwasser (DanielRosenwasser) added 6 commits April 29, 2022 01:16
@DanielRosenwasser
Stop erroring on JSON module imports in node ESM since they're no lon…
8b1e656
…ger experimental.
@DanielRosenwasser
Accepted baselines.
ce98f0a
@DanielRosenwasser
More refactoring, do the same checks for for-await loops.
fac5ded
@DanielRosenwasser
Accepted baselines.
5305796
@DanielRosenwasser
Adjust phrasing to permit for-await on CJS error.
1ca971d
@DanielRosenwasser
Accepted baselines.
4c46f26
@DanielRosenwasser

Daniel Rosenwasser (DanielRosenwasser) commented Apr 29, 2022

Copy link
Copy Markdown
Member Author

Most recent changes remove the error message for importing a JSON module under Node16 and NodeNext.

weswigham reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@DanielRosenwasser Daniel Rosenwasser (DanielRosenwasser) mentioned this pull request Apr 29, 2022
[do not merge] Add node16 to jsconfig, swap from node12 to node16 in tsconfig. SchemaStore/schemastore#2216
Merged
Daniel Rosenwasser (DanielRosenwasser) added 2 commits April 29, 2022 01:37
@DanielRosenwasser
Accepted baselines.
830871c
@DanielRosenwasser
Fix lints.
9d7fae8
@DanielRosenwasser

Daniel Rosenwasser (DanielRosenwasser) commented Apr 29, 2022

Copy link
Copy Markdown
Member Author

A decent amount of stuff seems to already use/support Node 12.

https://cs.github.com/?scopeName=All+repos&scope=&q=%22%5C%22module%5C%22%3A+%5C%22node12%5C%22%22+language%3A%22JSON+with+Comments%22

Should we keep it undocumented and provide an error when using it, but continue supporting it otherwise?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@weswigham

Wesley Wigham (weswigham) commented Apr 30, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

I mean, as I said back in the issue, I'm all for having newer stable versions to match the node versions people wanna target, alongside the existing versions we support, in the same way we build out a new esXXXX target every year (potentially if only to match up that node version to the correct esXXXX target automatically). If we only do even-numbered (and thus LTS) node versions, we should only need to add one every year or so as well.

Sounds like we have fairly good reasons to have both node16 and node18, in addition to 12, since 16 has all those fun es2022 features and 18 has stablized tla and JSON imports, while 12 already has some use.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@DanielRosenwasser

Daniel Rosenwasser (DanielRosenwasser) commented May 2, 2022

Copy link
Copy Markdown
Member Author

Spoke with Anders Hejlsberg (@ahejlsberg) and Andrew Branch (@andrewbranch) on this. We could just say Node18 as the initial minimum target which would simplify a bit for us; however, like you've mentioned, Node 18 can get more and it's not yet the active LTS. So let's start with Node 16 and if we see anything that diverges, we can add a Node18 target down the line.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@DanielRosenwasser
Daniel Rosenwasser (DanielRosenwasser) requested a review from Jake Bailey (jakebailey) May 2, 2022 21:57
@DanielRosenwasser

Daniel Rosenwasser (DanielRosenwasser) commented May 2, 2022

Copy link
Copy Markdown
Member Author

Consensus was on not providing a workaround for nightly-only users. Either you have nightly TS in a lockfile or you've signed yourself up to staying up-to-date.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@weswigham

Wesley Wigham (weswigham) commented May 2, 2022

Copy link
Copy Markdown
Member

Just remember that any perceived simplicity from initially supporting fewer explicit node versions is very likely a short-lived pipe dream at best - we will have to add more, the same way we add esXXXX targets every year. The kind of big-bang module system update that happened with the esm transition is not how node usually does development, usually you get more minor changes each release, as we can already see between 12, 14, 16, and 18. (And the only reason we didn't see a need to update the commonjs resolver for so long is because all those minor resolver changes were being banked up for the node 12 esm drop - even the cjs ones.) If the issue is the perceived complexity or messaging of many targets, that can is only being kicked, not fundamentally solved.

IMO, a longer term more complete solution would be following in the footsteps of... pretty much every js transforming tool in the js community (eg, babel via preset-env, rollup's target argument), and taking arbitrary engine versions/ranges and mapping them automatically to our internal feature flags (eg, es target, module (resolution), and emit features). That would be more predictable into the future, imo. Messaging is probably simpler: 'specify all desired target runtimes, eg target: node18.1.1,chrome101,firefox102,... and we'll figure out the rest.' where you can even specify future versions we don't explicitly handle yet and we can assume those map to next variants of our various features until we add explicit mappings.

chriskrycho reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

andrewbranch
Andrew Branch (andrewbranch) approved these changes May 3, 2022
View reviewed changes
@DanielRosenwasser
Daniel Rosenwasser (DanielRosenwasser) merged commit 5f9c9a6 into main May 3, 2022
@DanielRosenwasser
Daniel Rosenwasser (DanielRosenwasser) deleted the toNode16 branch May 3, 2022 23:29
Chris Krycho (chriskrycho) added a commit to true-myth/true-myth that referenced this pull request May 5, 2022
@chriskrycho
Use 'Node16' to support TS 4.7
5c4d82f
See microsoft/TypeScript#48879 for background
@chriskrycho Chris Krycho (chriskrycho) mentioned this pull request May 5, 2022
Use 'Node16' to support TS 4.7 true-myth/true-myth#376
Merged
sheetalkamat
Sheetal Nandi (sheetalkamat) reviewed May 5, 2022
View reviewed changes
Comment thread .../tsbuild/moduleSpecifiers/synthesized-module-specifiers-across-projects-resolve-correctly.js
@@ -134,296 +134,33 @@ Output::

[12:00:26 AM] Building project '/src/src-types/tsconfig.json'...

[12:00:33 AM] Project 'src/src-dogs/tsconfig.json' is out of date because output file 'src/src-dogs/dog.js' does not exist

@sheetalkamat Sheetal Nandi (sheetalkamat) May 5, 2022

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you fix the tests to modify lib file so there are no errors are we are really testing the scenario.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@sheetalkamat Sheetal Nandi (sheetalkamat) May 5, 2022

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created #48974

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
sheetalkamat
Sheetal Nandi (sheetalkamat) reviewed May 5, 2022
View reviewed changes
Comment thread ...-in-output-declaration-file-from-referenced-project-correctly-with-cts-and-mts-extensions.js
@@ -16,7 +16,7 @@ export type TheNum = 42;
export type { TheNum } from './const.cjs';

//// [/user/username/projects/myproject/packages/pkg2/tsconfig.json]
{"compilerOptions":{"composite":true,"outDir":"build","module":"node12"}}
{"compilerOptions":{"composite":true,"outDir":"build","module":"node16"}}

//// [/user/username/projects/myproject/packages/pkg2/package.json]

@sheetalkamat Sheetal Nandi (sheetalkamat) May 5, 2022

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for this

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@sheetalkamat Sheetal Nandi (sheetalkamat) mentioned this pull request May 5, 2022
Fix node16 tests for module resolution #48974
Merged
@balazsorban44 Balázs Orbán (balazsorban44) mentioned this pull request May 30, 2022
fix: always write moduleResolution to tsconfig.json vercel/next.js#37302
Closed
11 tasks
@nickytonline Nick Taylor (nickytonline) mentioned this pull request Jun 28, 2022
feat: add support for in-memory cache netlify/hydrogen-platform#37
Merged
@microsoft Microsoft (microsoft) locked as resolved and limited conversation to collaborators Oct 22, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

@sheetalkamat Sheetal Nandi (sheetalkamat) sheetalkamat left review comments
@andrewbranch Andrew Branch (andrewbranch) andrewbranch approved these changes
@weswigham Wesley Wigham (weswigham) Awaiting requested review from weswigham
@ahejlsberg Anders Hejlsberg (ahejlsberg) Awaiting requested review from ahejlsberg
@jakebailey Jake Bailey (jakebailey) Awaiting requested review from jakebailey

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@DanielRosenwasser Daniel Rosenwasser (DanielRosenwasser)

Labels

Author: Team For Milestone Bug PRs that fix a bug with a specific milestone

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Switch from node12 to node16 to avoid top-level await issues

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@DanielRosenwasser @weswigham @andrewbranch @sheetalkamat @typescript-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.