I'm new to Node and In this package.json for React Typescript project I understand what rimraf
does but what is the --tsconfig
doing at the end?
When I run the prebuild
script I see that the file typedoc.json is deleted. But why this --tsconfig
? There is a tsconfig.json file but I can’t see that rimraf
is doing anything
"scripts": {
"build": "tsdx build --transpileOnly --entry ./src/index.js",
"prebuild": "npm run docs",
"prepublishOnly": "npm run build",
"docs": "rimraf typedoc.json && typedoc --tsconfig",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx"
},
The source for this code is notistack package.json
CodePudding user response:
Firstly, rimraf
will not do anything to the tsconfig.json
file. It’s important to understand that the docs
script in the package.json file, i.e. this part;
"docs": "rimraf typedoc.json && typedoc --tsconfig",
consists of two separate commands and together they are referred to as a "compound command".
The typedoc --tsconfig
part is the second command and it’s not part of the rimraf
command because it’s on the right-hand side of the &&
operator. The --tsconfig
part is actually an argument for the typedoc
command (...it is not an argument for the rimraf
command).
Essentially the typedoc
command and its associated --tsconfig
argument, that is on the right-hand side of the &&
operator, is only invoked if the command on the left-hand side of it, (i.e. the first command rimraf typedoc.json
), completes successfully with a zero exit code.
The typedoc
command is what generates documentation for TypeScript projects.
The --tsconfig
argument for thé typedoc
command is described as follows in the documentation
--tsconfig <path/to/tsconfig.json>
Specify a typescript config file that should be loaded. If not specified TypeDoc will look for 'tsconfig.json' in the current directory.
Note: In your usage of the --tsconfig
argument it doesn’t specify a custom filepath to the tsconfig.json
file, therefore it utilizes the one in the current directory.