microsoft / tsdoc

A doc comment standard for TypeScript
https://tsdoc.org/
MIT License
4.71k stars 131 forks source link

fail to call console.log to print in tsdoc/src #245

Closed yuzhidi closed 4 years ago

yuzhidi commented 4 years ago

Hi, I want to print in tsdoc/src to understand some logic, but compiling fail to using consolg.log(). Is there any suggestion to print? thx!

build log: `$ rush build Found configuration in D:\study\tsdoc\rush.json

Rush Multi-Project Build Tool 5.23.2 - https://rushjs.io Node.js version is 10.21.0 (LTS)

Found configuration in D:\study\tsdoc\rush.json

Starting "rush build"

Executing a maximum of 11 simultaneous processes...

[@microsoft/tsdoc] started

0 of 5: [@microsoft/tsdoc] failed! 1 of 5: [@microsoft/tsdoc-config] blocked by [@microsoft/tsdoc]! 2 of 5: [eslint-plugin-tsdoc] blocked by [@microsoft/tsdoc]! 3 of 5: [api-demo] blocked by [@microsoft/tsdoc]! 4 of 5: [tsdoc-playground] blocked by [@microsoft/tsdoc]!

BLOCKED (4)

@microsoft/tsdoc-config api-demo eslint-plugin-tsdoc tsdoc-playground

FAILURE (1)

@microsoft/tsdoc (3.49 seconds)

@microsoft/tsdoc node ./build.js -- TYPESCRIPT -- src/parser/Tokenizer.ts(18,5): error TS2584: Cannot find name 'console'. Do you need to change your targe t library? Try changing the lib compiler option to include 'dom'. ERROR: Command failed: D:\study\tsdoc\tsdoc\node_modules.bin\tsc

[@microsoft/tsdoc] Returned error code: 1

Error: Project(s) failed rush build - Errors! (5.48 seconds) `

octogonz commented 4 years ago

Did you remember to run rush install?

Full instructions are here: https://github.com/microsoft/tsdoc/blob/master/Contributing.md

yuzhidi commented 4 years ago

Did you remember to run rush install?

Full instructions are here: https://github.com/microsoft/tsdoc/blob/master/Contributing.md

$ rush install --bypass-policy Found configuration in D:\study\tsdoc\rush.json

Rush Multi-Project Build Tool 5.23.2 - https://rushjs.io Node.js version is 10.21.0 (LTS)

Found configuration in D:\study\tsdoc\rush.json

Starting "rush install"

Trying to acquire lock for pnpm-4.12.5 Acquired lock for pnpm-4.12.5 Found pnpm version 4.12.5 in C:\Users\Administrator.rush\node-v10.21.0\pnpm-4.12.5

Symlinking "D:\study\tsdoc\common\temp\pnpm-local" --> "C:\Users\Administrator.rush\node-v10.21.0\pnpm-4.12.5"

Updating temp projects in D:\study\tsdoc\common\temp\projects Copying D:\study\tsdoc\common\config\rush.npmrc --> D:\study\tsdoc\common\temp.npmrc Updating D:\study\tsdoc\common\temp\pnpmfile.js Finished creating temporary modules (0.19 seconds)

Checking node_modules in D:\study\tsdoc\common\temp

Skipping linking -- everything is already up to date.

Rush install finished successfully. (0.30 seconds)

80279969@P80279969 ~/study/tsdoc/tsdoc $ rush build Found configuration in D:\study\tsdoc\rush.json

Rush Multi-Project Build Tool 5.23.2 - https://rushjs.io Node.js version is 10.21.0 (LTS)

Found configuration in D:\study\tsdoc\rush.json

Starting "rush build"

Executing a maximum of 11 simultaneous processes...

[@microsoft/tsdoc] started

0 of 5: [@microsoft/tsdoc] failed! 1 of 5: [@microsoft/tsdoc-config] blocked by [@microsoft/tsdoc]! 2 of 5: [eslint-plugin-tsdoc] blocked by [@microsoft/tsdoc]! 3 of 5: [api-demo] blocked by [@microsoft/tsdoc]! 4 of 5: [tsdoc-playground] blocked by [@microsoft/tsdoc]!

BLOCKED (4)

@microsoft/tsdoc-config api-demo eslint-plugin-tsdoc tsdoc-playground

FAILURE (1)

@microsoft/tsdoc (5.16 seconds) \>>> @microsoft/tsdoc node ./build.js \-- TYPESCRIPT -- src/parser/Tokenizer.ts(19,5): error TS2584: Cannot find name 'console'. Do you need to change your target library? Try changing the l ib compiler option to include 'dom'. ERROR: Command failed: D:\study\tsdoc\tsdoc\node_modules.bin\tsc

\[@microsoft/tsdoc] Returned error code: 1

Error: Project(s) failed rush build - Errors! (7.10 seconds)

\$ git diff diff --git a/tsdoc/src/parser/Tokenizer.ts b/tsdoc/src/parser/Tokenizer.ts index d0b4204..ff0c9b4 100644 \--- a/tsdoc/src/parser/Tokenizer.ts \+++ b/tsdoc/src/parser/Tokenizer.ts \@@ -16,7 +16,7 @@ export class Tokenizer { */ public static readTokens(lines: TextRange[]): Token[] { Tokenizer._ensureInitialized(); \- \+ console.log("") const tokens: Token[] = [];

octogonz commented 4 years ago

Ohhhh I see, this error is involving new code that you added to the project. I apologize, I did not realize that before.

If you want TypeScript to find the console.log() API, then you need import it into your environment. Since we are testing on Node.js, you can add node types like this:

First install the NPM package:

$ cd D:\study\tsdoc\tsdoc
$ rush add --package @types/node --dev

Then configure TypeScript to use it, by updating D:\study\tsdoc\tsdoc\tsconfig.json:

    . . . 
    "types": [
      "jest",
      "node"      // <--- add this line
    ],
    . . . 
yuzhidi commented 4 years ago

thx very much!