Skip to content

TS5055 error while import a non relative json module with resolveJsonModule option #24715

Description

@grayflow

TypeScript Version: 3.0.0-dev.20180605

Search Terms: TS5055 resolveJsonModule

Code

tsjson> find .
.
./main.ts
./json
./json/myjson.json
./tsconfig.json
./src
./src/test.ts

tsconfig.json:

{
"compilerOptions": {
"target": "es5",
"module": "es2015",
"moduleResolution": "node",
"baseUrl": "./",
"resolveJsonModule": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"noEmitOnError": true
},
"include": [
"main.ts",
"src",
"json"
],
"exclude": [
"node_modules"
]
}

main.ts:

import"test";

src/test.ts:

importmyjsonfrom"json/myjson.json";console.log('hello world!',myjson.message);export{}

json/myjson.json:

{
"message": "to be continue..."
}

Expected behavior:
compile successful

Actual behavior:
tsjson> tsc
error TS5055: Cannot write file '*************/tsjson/json/myjson.json' because it would overwrite input file.

Playground Link:

Related Issues:

Metadata

Metadata

Assignees

No one assigned

    Labels

    FixedA PR has been merged for this issueWorking as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions