Skip to content
This repository has been archived by the owner on May 19, 2022. It is now read-only.

'Cannot parse tsconfig.extend.json' error #23

Closed
fedorinoGore opened this issue Feb 1, 2021 · 7 comments
Closed

'Cannot parse tsconfig.extend.json' error #23

fedorinoGore opened this issue Feb 1, 2021 · 7 comments

Comments

@fedorinoGore
Copy link

fedorinoGore commented Feb 1, 2021

Im following the readme instructions but constantly having error "Cannot parse tsconfig.extend.json"
Option "debug: true" doesn't work, at least I don't see any additional info in the console

Here are my config files:
craco.config.js

module.exports = {
    plugins: [
        {
            plugin: require('craco-alias'),
            options: {
                debug: true,
                source: 'tsconfig',
                tsConfigPath: './tsconfig.extend.json',
                baseUrl: './src'
            }
        }
    ],
    style: {
        postcss: {
            plugins: [require('tailwindcss'), require('autoprefixer')]
        }
    }
}

tsconfig.json

{
"extends": "./tsconfig.extend.json",
  "compilerOptions": {
    "target": "es5",
    "lib": [
      "dom",
      "dom.iterable",
      "esnext"
    ],
    "allowJs": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "noFallthroughCasesInSwitch": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react-jsx"
  },
  "include": [
    "src"
  ]
}

tsconfig.extend.json

{
    "compilerOptions": {
        "baseUrl": "./src",
        "paths": {
            "@components/*": [
                "./components/*"
            ],
        },
    }
}

Having this deps in package.json:

{
  ...
"@craco/craco": "^6.1.0",
"react-scripts": "4.0.1",
"craco-alias": "^2.1.1",
"typescript": "4.1.3"
}
@katsimoto
Copy link

tsconfig.extend.json is not valid, please check the syntax

@fedorinoGore
Copy link
Author

@VyacheslavR could you please give me a hint - what's wrong with tsconfig.extend.json?

@katsimoto
Copy link

katsimoto commented Feb 10, 2021

@fedorinoGore, you put commas at the end, if it was js, it would be ok, but in json it is not valid. Here is a valid example:

{
    "compilerOptions": {
        "baseUrl": "./src",
        "paths": {
            "@components/*": [
                "./components/*"
            ]
        }
    }
}

@yomiAdenaike01
Copy link

Go to this file path craco-alias/plugin/pre-check/check-config-contents.js and then in the first try and catch add the err property to the string output just do what is says and then it will be correct, or you can put the file as json initially or put it through a JSON parser to check it for errors and then put it in the extend.json

@renyuanz
Copy link

beyond the ending commas, just be aware of removing all comments in the tsconfig.extend.json as comments are not allowed in the JSON file...

@risen228
Copy link
Owner

I updated the message to make it easier to find the syntax error.

@ui-yazan-abbas
Copy link

@katsimoto Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants