TypeStrong / typedoc

Documentation generator for TypeScript projects.
https://typedoc.org
Apache License 2.0
7.77k stars 701 forks source link

exclude doesnt work at all in @0.21.2 #1620

Closed Ashimriat closed 3 years ago

Ashimriat commented 3 years ago

Search terms

exclude, bug

Expected Behavior

I have a project on Typescript which correctly builds and launches I expect for Typedoc to generate documentation for specified file correctly

Actual Behavior

Documentation build fails with following errors:

``` Error: node_modules/@types/react/index.d.ts:121:51 - error TS2344: Type 'C' does not satisfy the constraint 'ElementType'. Type 'string | number | ForwardRefExoticComponent | (new (props: any) => Component) | ((props: any, context?: any) => ReactElement> | null)' is not assignable to type 'ElementType'. Type 'number' is not assignable to type 'ElementType'. Type 'C' is not assignable to type 'FunctionComponent'. Type 'string | number | ForwardRefExoticComponent | (new (props: any) => Component) | ((props: any, context?: any) => ReactElement> | null)' is not assignable to type 'FunctionComponent'. Type 'string' is not assignable to type 'FunctionComponent'. 121 "ref" extends keyof ComponentPropsWithRef ~ Error: node_modules/@types/react/index.d.ts:122:49 - error TS2344: Type 'C' does not satisfy the constraint 'ElementType'. Type 'C' is not assignable to type 'FunctionComponent'. 122 ? NonNullable["ref"]> extends Ref< ~ Error: node_modules/@vue/runtime-dom/dist/runtime-dom.d.ts:1420:15 - error TS2320: Interface 'Element' cannot simultaneously extend types 'VNode' and 'ReactElement'. Named property 'props' of types 'VNode' and 'ReactElement' are not identical. 1420 interface Element extends VNode {} ~~~~~~~ Error: node_modules/@vue/runtime-dom/dist/runtime-dom.d.ts:1420:15 - error TS2320: Interface 'Element' cannot simultaneously extend types 'VNode' and 'ReactElement'. Named property 'type' of types 'VNode' and 'ReactElement' are not identical. 1420 interface Element extends VNode {} ~~~~~~~ Error: node_modules/@vue/runtime-dom/dist/runtime-dom.d.ts:1427:15 - error TS2430: Interface 'IntrinsicElements' incorrectly extends interface 'NativeElements'. Types of property 'symbol' are incompatible. Type 'SVGProps' is not assignable to type 'ElementAttrs'. Type 'SVGProps' is not assignable to type 'SVGAttributes'. Types of property 'autoReverse' are incompatible. Type 'Booleanish | undefined' is not assignable to type 'Numberish | undefined'. Type 'false' is not assignable to type 'Numberish | undefined'. 1427 interface IntrinsicElements extends NativeElements { ~~~~~~~~~~~~~~~~~ Error: node_modules/@vue/runtime-dom/dist/runtime-dom.d.ts:1432:15 - error TS2320: Interface 'IntrinsicAttributes' cannot simultaneously extend types 'ReservedProps' and 'Attributes'. Named property 'key' of types 'ReservedProps' and 'Attributes' are not identical. 1432 interface IntrinsicAttributes extends ReservedProps {} ~~~~~~~~~~~~~~~~~~~ Error: shims/vuex.d.ts:2:38 - error TS2307: Cannot find module '@store/modules/text' or its corresponding type declarations. 2 import type { StoreTextModule } from '@store/modules/text'; ```

Steps to reproduce the bug

package.json ```json { "scripts": { "dev:server": "webpack serve --mode=development", "prod:build": "webpack --mode=production", "test": "jest --config=.jestrc.js --no-cache", "test:snapshotsUpdate": "run test -- -u", "test:coverage": "test -- --coverage=true", "docs": "jsdoc -c .jsdocrc.js -r", "docsTs": "typedoc --options .typedocrc.js", "storyServ": "start-storybook -p 6006 -c storybook --no-manager-cache", "storyBuild": "build-storybook -c storybook" }, "license": "MIT", "dependencies": { "@fortawesome/fontawesome-svg-core": "^1.2.35", "@fortawesome/free-solid-svg-icons": "^5.15.3", "@fortawesome/vue-fontawesome": "^3.0.0-4", "reflect-metadata": "^0.1.13", "vue": "^3.1.1", "vue-property-decorator": "^10.0.0-rc.3", "vuex": "^4.0.2", "vuex-class-modules": "^1.3.0" }, "devDependencies": { "@babel/core": "^7.14.6", "@babel/node": "^7.14.7", "@babel/preset-env": "^7.14.7", "@storybook/addon-essentials": "^6.3.2", "@storybook/addon-links": "^6.3.2", "@storybook/addon-storyshots": "^6.3.2", "@storybook/builder-webpack5": "^6.3.2", "@storybook/cli": "^6.3.2", "@storybook/manager-webpack5": "^6.3.2", "@storybook/vue3": "^6.3.2", "@types/jest": "^26.0.23", "@typescript-eslint/eslint-plugin": "^4.27.0", "@typescript-eslint/parser": "^4.27.0", "@vue/compiler-sfc": "^3.1.1", "@vue/composition-api": "^1.0.0-rc.12", "@vue/test-utils": "^2.0.0-rc.8", "@yarnpkg/pnpify": "^3.0.0-rc.7", "babel-jest": "^26.6.3", "babel-loader": "^8.2.2", "better-docs": "^2.3.2", "copy-webpack-plugin": "^9.0.0", "css-loader": "^5.2.6", "eslint": "^7.29.0", "eslint-config-airbnb-typescript": "^12.3.1", "eslint-import-resolver-alias": "^1.1.2", "eslint-plugin-import": "^2.23.4", "eslint-plugin-jest": "^24.3.6", "eslint-plugin-jsdoc": "^35.4.0", "eslint-plugin-vue": "^7.11.1", "eslint-webpack-plugin": "^2.5.4", "html-webpack-plugin": "^5.3.1", "jest": "^26.6.3", "jest-cucumber-fusion": "^0.8.1", "jest-serializer-vue": "^2.0.2", "jsdoc": "^3.6.7", "pnp-webpack-plugin": "^1.6.4", "pug": "^3.0.2", "pug-bem-plain-loader": "^1.1.5", "sass": "^1.25.0", "sass-loader": "^12.1.0", "stylelint": "^13.13.1", "stylelint-config-airbnb": "0.0.0", "stylelint-order": "^4.1.0", "stylelint-scss": "^3.19.0", "stylelint-webpack-plugin": "^2.2.1", "ts-jest": "^26.5.6", "ts-loader": "^9.2.3", "typedoc": "^0.21.2", "typescript": "^4.3.4", "vue-class-component": "^8.0.0-rc.1", "vue-eslint-parser": "^7.6.0", "vue-jest": "^5.0.0-alpha.10", "vue-loader": "^16.3.0", "vue-style-loader": "^4.1.3", "webpack": "^5.39.1", "webpack-cli": "^4.7.2", "webpack-dev-server": "^3.11.2" } } ```
tsconfig.json ```jsonc { "include": [ "src/**/*.vue", "src/**/*.ts", ], "exclude": [ "tools", "node_modules", "storybook", "tests" ], "files": [ "shims/vue.d.ts", "shims/vuex.d.ts", "shims/images.d.ts", ], "compilerOptions": { "baseUrl": "./", "outDir": "dist", "allowSyntheticDefaultImports": true, "declaration": true, "declarationDir": "dist/types", "esModuleInterop": true, "target": "esnext", "module": "esnext", "lib": ["esnext", "dom"], "strict": true, "jsx": "preserve", "sourceMap": true, "moduleResolution": "node", "experimentalDecorators": true, "allowJs": true, "paths": { "@jwe/utils": ["src/tools/utils.ts"], "@jwe/interfaces": ["src/tools/interfaces.ts"], "@jwe/*": ["src/*"] }, } } ```

command used to run typedoc:

npm run docsTs
.typedocrc.js ```js module.exports = { name: 'Test Name', includeVersion: true, hideGenerator: true, excludeNotDocumented: true, entryPoints: [ 'src/store/modules/text.ts' ], exclude: [ 'shims/**/*.ts', ], externalPattern: [ 'node_modules/**/*.ts', ], excludeExternals: true, disableSources: true, media: 'src/assets', out: 'documentation', listInvalidSymbolLinks: true, readme: 'none', watch: true, } ```

project structure:

node_modules
shims
package.json
tsconfig.json
.typedocrs.js
src
  => components (Vue SFC here)
  => store
  => modules
    => text.ts

currently tested code:

```ts /** * @module Text * @description Модуль, отвечающий за операции над текстовыми элементами * @category Store */ import { VuexModule, Mutation, Module, } from 'vuex-class-modules'; import { generateUUID } from '../../tools/utils'; import type { DeepPartial, RequireAtLeastOne } from '../../tools/helperTypes'; /** * @category Store * @subcategory Text */ type TextScrollControlsPosition = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'; /** * @category Store * @subcategory Text */ type HexColor = `#${string}`; /** * @category Store * @subcategory Text */ type TextFontWeight = 300 | 600; /** * @category Store * @subcategory Text */ type TextDecoration = 'none' | 'underline'; /** * @category Store * @subcategory Text */ type TextFontStyle = 'normal' | 'italic'; /** * @category Store * @subcategory Text */ type TextAlign = 'left' | 'center' | 'right' | 'justify'; /** * @category Store * @subcategory Text */ type TextElementData = { /** * Стили */ style: { /** * Приоритетность слоя */ zIndex: number; /** * Прозрачность (от 0 до 100) */ opacity: number; /** * Шрифт */ fontFamily: string; /** * Размер шрифта */ fontSize: number; /** * Насыщенность шрифта * @type {TextFontWeight} */ fontWeight: TextFontWeight; /** * Вид текста (обычный или курсив) */ fontStyle: TextFontStyle; /** * Декорация текста (обычный или подчеркнутый) */ textDecoration: TextDecoration; /** * Цвет текста */ color: HexColor; /** * Цвет подложки текста */ backgroundColor: HexColor; /** * Выравнивание */ align: TextAlign; } /** * Положение */ coords: { /** * От верхней границы слайда */ top: number; /** * От левой границы слайда */ left: number; } /** * Прокрутка */ scroll: { /** * Можно ли прокручивать текст */ isScrollDisplayed: boolean; /** * На сколько уже прокручен */ scrollPos: number; /** * Положение управления прокруткой */ position: TextScrollControlsPosition; } } /** * @extends TextElementData * @category Store * @subcategory Text */ type TextElement = TextElementData & { /** * Уникальный id */ uid: string; } /** * @category Store * @subcategory Text */ type TextElementUpdateData = RequireAtLeastOne>; /** * @description Формат данных, передающихся для обновления состояния текстовых элементов * @category Store * @subcategory Text */ type TextElementUpdateInfo = { /** * uid элемента, который нужно апдейтнуть */ uid: string; /** * Данные, которые надо обновить * @type {TextElementUpdateData} */ data: TextElementUpdateData; }; /** * @category Store * @subcategory Text */ interface TextModule { /** * @description Активные текстовые элементы * @type {TextElement[]} */ elements: TextElement[]; /** * @method addElement * @description Добавляет новый текстовый элемент */ addElement(): void; /** * @method removeElement * @description Удаляет текстовый элемент * @param {string} uid - uid текстового элемента */ removeElement(uid: string): void; /** * @method updateElement * @description Обновляет данные текстового элемента * @param {TextElementUpdateInfo} updateInfo - Данные об обновляемом элементе * @todo сделать правильный тип. * Должно быть хотя бы одно поле {@link TextElementData} * с хотя бы одним из его соответствующих свойств */ updateElement(updateInfo: TextElementUpdateInfo): void; } const generateTextElement = (): TextElement => ({ uid: generateUUID(), coords: { top: 0, left: 0, }, style: { zIndex: 0, opacity: 100, fontFamily: 'Segoe UI', fontSize: 48, fontWeight: 300, fontStyle: 'normal', textDecoration: 'none', color: '#000000', backgroundColor: '#ffffff', align: 'left', }, scroll: { isScrollDisplayed: false, scrollPos: 0, position: 'top-left', }, }); /** * @class * @implements TextModule * @category Store */ @Module export default class Text extends VuexModule implements TextModule { elements = [] as TextElement[]; @Mutation public addElement(): void { this.elements.push(generateTextElement()); } @Mutation public removeElement(uid: string): void { const removedElementIndex = this.elements.findIndex((el) => uid === el.uid); this.elements.splice(removedElementIndex, 1); } @Mutation public updateElement({ uid, data }: TextElementUpdateInfo): void { const updatedElementIndex = this.elements.findIndex((el) => uid === el.uid); const updatedElement = this.elements[updatedElementIndex]; const updateObject = ( Object.keys(data) as Array ).reduce((acc, key) => { (acc[key] as any) = { ...updatedElement[key], ...data[key], }; return acc; }, {} as Partial); this.elements.splice(updatedElementIndex, 1, { ...this.elements[updatedElementIndex], ...updateObject, }); } } export type { TextElement, TextModule }; ```

Environment

Gerrit0 commented 3 years ago

This doesn't seem to have anything to do with the exclude option. Excluding node_modules in your tsconfig does not mean that files it in will not be considered when compiling for types. It means that those files will not be compiled and produce .js output.

You will see the same errors if you compile with npx tsc -p tsconfig.json. Having both Vue and React types installed is causing problems since they have conflicting types. If you set the skipLibCheck option, TypeScript will ignore errors in node_modules and TypeDoc will be able to execute.

Ashimriat commented 3 years ago

Builds without any problems now! Thank you very much ^^