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

Specialized error message for setting lib or target to a future ES version #60219

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

uhyo
Copy link
Contributor

@uhyo uhyo commented Oct 14, 2024

Fixes #60050

This PR improves the diagnostic message for unsupported lib or target values by emitting a specialized message when the specified value looks like a future ES version.

I altered the originally suggested message a bit because printing a concrete TypeScript version in the error message felt a skosh unusual to me, instead using the phrase this version of TypeScript. Of course I'm open to any change suggested by reviewers.

Example

tsconfig.json

{
  "compilerOptions": {
    "target": "es2099",
    "lib": ["es2098", "dom"],
  },
  "include": ["src"]
}

🏠 Current Behavior

tsconfig.json:3:15 - error TS6046: Argument for '--target' option must be: 'es5', 'es6', 'es2015', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'esnext'.

3     "target": "es2099",
                ~~~~~~~~

tsconfig.json:4:13 - error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'esnext', 'dom', 'dom.iterable', 'dom.asynciterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'webworker.asynciterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2016.intl', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.sharedmemory', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'es2023.intl', 'esnext.array', 'esnext.collection', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.disposable', 'esnext.bigint', 'esnext.string', 'esnext.promise', 'esnext.weakref', 'esnext.decorators', 'esnext.object', 'esnext.regexp', 'esnext.iterator', 'decorators', 'decorators.legacy'.

4     "lib": ["es2098", "dom"],
              ~~~~~~~~

🌟 New Behavior

tsconfig.json:3:15 - error TS6284: Argument 'es2099' for '--target' option is a year not yet supported by this version of TypeScript.

3     "target": "es2099",
                ~~~~~~~~

tsconfig.json:4:13 - error TS6284: Argument 'es2098' for '--lib' option is a year not yet supported by this version of TypeScript.

4     "lib": ["es2098", "dom"],
              ~~~~~~~~

@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Oct 14, 2024
@typescript-bot
Copy link
Collaborator

The TypeScript team hasn't accepted the linked issue #60050. If you can get it accepted, this PR will have a better chance of being reviewed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Uncommitted Bug PR for untriaged, rejected, closed or missing bug
Projects
Status: Not started
Development

Successfully merging this pull request may close these issues.

Specialized error message when too new a lib is provided
2 participants