Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: add TypeScript execution requirements #44030

Closed
wants to merge 16 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 49 additions & 1 deletion doc/contributing/maintaining-types-for-nodejs.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ code of their JavaScript projects. While many people don't annotate their code,
or make use of annotations at all, there are enough who do that the project has
agreed it's important to work towards having [suitable types for end-users][].

## High level approach
## High level approach - maintaining types

There are a number of ways that types could be maintained for Node.js ranging
from shipping them with the Node.js runtime to having them be externally
Expand All @@ -28,6 +28,54 @@ The agreement was that the ideal flow would be as follows:
* Automation within external type projects consumes the JSON and automatically
generates a PR to add the API.

## High level approach - development workflow

The number of people using TypeScript with Node.js is significant enough
that providing a good developer experience is important. While TypeScript
is identified specifically, a secondary goal is that what we provide to improve
development experience with TypeScrtipt would apply to other type
mhdawson marked this conversation as resolved.
Show resolved Hide resolved
aduh95 marked this conversation as resolved.
Show resolved Hide resolved
systems as well.
mhdawson marked this conversation as resolved.
Show resolved Hide resolved

We have agreed that the approach will `NOT` include bundling TypeScript
mhdawson marked this conversation as resolved.
Show resolved Hide resolved
aduh95 marked this conversation as resolved.
Show resolved Hide resolved
tools with Node.js but instead improve the developer experience for how
those tools are installed/configured to work with Node.js.

The high level developer experience we are working towards was captured in the
[next-10 TypeScript mini-summit](https://github.com/nodejs/next-10/pull/150)
and is as follows:

1. Users can ask Node.js to execute a file which is not one of the types it
can execute by default (.js, .mjs, etc.). For example `node script.ts`.
2. On startup Node.js will look for a config which is in the scope of the
mhdawson marked this conversation as resolved.
Show resolved Hide resolved
file being executed.
3. If no config is found, Node.js will echo either:
* If the file was a TypeScript file, a TypeScript specific message with a
reference to a link on Nodejs.org on how to install required components
for TypeScript and how to add the associated config.
* If the file was not a TypeScript file, a generic message
mhdawson marked this conversation as resolved.
Show resolved Hide resolved
4. If a config is found, Node.js will extract the Node.js options for
that config and apply them as if they had been provided on the command
line.
5. Assuming the options associated with the config add support for the
type of file being loaded, Node.js will execute the file as if it was one
of the file types it can execute by default.
aduh95 marked this conversation as resolved.
Show resolved Hide resolved

Some additional specifics around the current thinking include:
mhdawson marked this conversation as resolved.
Show resolved Hide resolved

* loaders already provide a number of the components needed to
mhdawson marked this conversation as resolved.
Show resolved Hide resolved
satisfy the requirements above. They already provide the Node.js
options that are needed to achieve many of the requirements above.
* package.json as the location for the config is potentially a good
mhdawson marked this conversation as resolved.
Show resolved Hide resolved
aduh95 marked this conversation as resolved.
Show resolved Hide resolved
choice as Node.js already looks for it as part of startup.
* The implementation chosen should allow for difference configuration in
for different enronments/conditions like prod,dev, etc.
mhdawson marked this conversation as resolved.
Show resolved Hide resolved
* We don't have consensus on provding an opinionated default but
that should be explored after the initial steps are complete.
* It will be important that as part of the messaging around this
functionality that we avoid confusion that could lead people to ship
TypeScript files (ex `script.ts`) instead of the processed files
(ex `script.js`).
mhdawson marked this conversation as resolved.
Show resolved Hide resolved

## Generation/Consumption of machine readable JSON files

When you run `make doc` the canonical markdown files used to
Expand Down