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

Compiler options reference page is wrong #16856

Closed
Venryx opened this issue Jun 30, 2017 · 0 comments
Closed

Compiler options reference page is wrong #16856

Venryx opened this issue Jun 30, 2017 · 0 comments
Labels
Docs The issue relates to how you learn TypeScript

Comments

@Venryx
Copy link

Venryx commented Jun 30, 2017

The compiler-options reference page here shows the following: (the third column is for the "default")

This is inaccurate.

I dug into Typescript's source-code, and actually, if "target" is set to any of ["es6", "es2015", "es2016", "es2017", "esNext"], then "module" defaults to "es6".

Here are the files where this can be seen:

Enum declaration: (from: https://github.com/Microsoft/TypeScript/blob/ac72803bb2b299e6b331329a9781cb73cc55c156/src/compiler/core.ts#L1595)

    const enum ScriptTarget {
        ES3 = 0,
        ES5 = 1,
        ES2015 = 2,
        ES2016 = 3,
        ES2017 = 4,
        ESNext = 5,
        Latest = 5,
    }

Module default-value logic: (from: https://github.com/Microsoft/TypeScript/blob/73ee2feb51c9b7e24a29eb4cee19d7c14b933065/lib/tsserverlibrary.d.ts#L2117)

    export function getEmitModuleKind(compilerOptions: CompilerOptions) {
        return typeof compilerOptions.module === "number" ?
            compilerOptions.module :
            getEmitScriptTarget(compilerOptions) >= ScriptTarget.ES2015 ? ModuleKind.ES2015 : ModuleKind.CommonJS;
    }

So the reference page should be updated to say "target >= ES6", not "target === ES6".

For reference, here is the issue on the ts-loader project where I discovered this mistake: TypeStrong/ts-loader#570 (comment)

@RyanCavanaugh RyanCavanaugh added Bug A bug in TypeScript Docs The issue relates to how you learn TypeScript labels Jun 30, 2017
@mhegazy mhegazy removed the Bug A bug in TypeScript label Aug 31, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
alipiry pushed a commit to alipiry/TypeScript-Handbook that referenced this issue Jan 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Docs The issue relates to how you learn TypeScript
Projects
None yet
Development

No branches or pull requests

3 participants