Skip to content

.json inputs not allowed outside of rootDir #38015

Closed
@duarten

Description

@duarten

TypeScript Version: Version 3.8.3

Search Terms: json rootDir

Code

Folder structure:

src/test.ts
src/tsconfig.json
data/dummy.json

tsconfig:

{
    "compilerOptions": {
        "esModuleInterop": true,
        "resolveJsonModule": true,
        "rootDirs": [
            ".",
            "../data"
        ]
    }
}

test.ts:

import dummy from "./dummy.json"

console.log(dummy)

Expected behavior:

JSON printed to stdout.

Actual behavior:

The error: src/test.ts:1:19 - error TS6059: File 'repro/data/dummy.json' is not under 'rootDir' 'repro/src'. 'rootDir' is expected to contain all source files.

Playground Link:

Related Issues:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions