Skip to content

Unreachable code defaults #25738

Open
Open
@kamek-pf

Description

@kamek-pf

Apparently, since 2.9.1, unreachable code is allowed by default, you have to explicitly set allowUnreachableCode to false in tsconfig.json to get the old behavior.

This doesn't match what's described in the docs.

image

Quick repro :
package.json

{
  "name": "tmp",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "dependencies": {
    "typescript": "2.9.1"
  }
}

tsconfig.json (default from tsc --init)

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "strict": true,
    "esModuleInterop": true
  }
}

index.ts

export const a = (): boolean => {
    return true;
    return false;
};

yarn tsc outputs no warning as of 2.9.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocsThe issue relates to how you learn TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions