doczjs / docz

✍ It has never been so easy to document your things!
https://docz.site
MIT License
23.6k stars 1.46k forks source link

How to fix Unknown compiler option 'importsNotUsedAsValues'. error? #1612

Open shooter01 opened 3 years ago

shooter01 commented 3 years ago

I have a project with following config files:


{
    "compilerOptions": {
        "outDir": "./dist",
        "module": "esnext",
        "target": "es5",
        "lib": ["es6", "dom"],
        "sourceMap": true,
        "allowJs": true,
        "jsx": "react",
        "moduleResolution": "node",
        "noImplicitReturns": true,
        "noImplicitThis": true,
        "noImplicitAny": true,
        "strictNullChecks": true,
        "baseUrl": "./",
        "rootDir": "./",
        "typeRoots": ["./node_modules/@types", "./src/@types"],
        "paths": {
            "@src/*": ["src/*"],
            "@images/*": ["src/images/*"],
            "@components/*": ["src/components/*"],
            "@pages/*": ["src/pages/*"],
            "@modules/*": ["src/modules/*"],
            "@hooks/*": ["src/hooks/*"],
            "@routing/*": ["src/routing/*"],
            "@utils/*": ["src/utils/*"],
            "@locales/*": ["src/locales/*"],
            "@gql/*": ["src/gql/*"]
        },
        "allowSyntheticDefaultImports": true,
        "esModuleInterop": true,
        "importsNotUsedAsValues": "preserve",
        "resolveJsonModule": true,
        "skipLibCheck": false
    },
    "exclude": [
        "node_modules",
        "webpack",
        "src/gql/types.ts",
        "src/**/*generated.ts"
    ]
}

My package.json file with "typescript": "4.1.2"

{
    "dependencies": {
        "react": "17.0.1",
        "react-dnd": "^11.1.3",
        "docz": "latest"
    }
}

I want create documentation for my components and run my docz app: yarn docz dev But it gives me an error:

ERROR

Failed to process data server

ERROR

{ file: undefined, start: undefined, length: undefined, messageText: "Unknown compiler option 'importsNotUsedAsValues'.", category: 1, code: 5023, reportsUnnecessary: undefined }

not finished source and transform nodes - 1.311s

If I remove importsNotUsedAsValues prop from tsconfig - the error goes away.

But how to handle the error WITH importsNotUsedAsValues prop ?