Open mmerfort opened 2 years ago
I don't use Typescript myself (Although I really want to, I haven't found the time to look into it). I've tried following your instructions, but running
./node_modules/typescript/bin/tsc
Throws the following:
error TS18003: No inputs were found in config file '/var/www/projects/typescript-test/tsconfig.json'. Specified 'include' paths were '["**/*"]' and 'exclude' paths were '[]'.
Found 1 error.
I'm assuming this isn't the issue you're referring to? Are you able to provide the error that you're seeing please?
The type definitions are all automatically generated from the doc blocks in the code. I'm happy for a PR to fix any faulty ones.
Sorry, I forgot to attach the actual error. Here it is:
$ npx tsc
node_modules/@dice-roller/rpg-dice-roller/types/dice/FudgeDice.d.ts:18:104 - error TS2304: Cannot find name 'Modifier'.
18 constructor(nonBlanks?: number | undefined, qty?: number | undefined, modifiers?: {} | Map<string, Modifier> | Modifier[] | null | undefined);
~~~~~~~~
node_modules/@dice-roller/rpg-dice-roller/types/dice/FudgeDice.d.ts:18:116 - error TS2304: Cannot find name 'Modifier'.
18 constructor(nonBlanks?: number | undefined, qty?: number | undefined, modifiers?: {} | Map<string, Modifier> | Modifier[] | null | undefined);
~~~~~~~~
node_modules/@dice-roller/rpg-dice-roller/types/dice/PercentileDice.d.ts:17:72 - error TS2304: Cannot find name 'Modifier'.
17 constructor(qty?: number | undefined, modifiers?: {} | Map<string, Modifier> | Modifier[] | null | undefined, sidesAsNumber?: boolean | undefined);
~~~~~~~~
node_modules/@dice-roller/rpg-dice-roller/types/dice/PercentileDice.d.ts:17:84 - error TS2304: Cannot find name 'Modifier'.
17 constructor(qty?: number | undefined, modifiers?: {} | Map<string, Modifier> | Modifier[] | null | undefined, sidesAsNumber?: boolean | undefined);
~~~~~~~~
node_modules/@dice-roller/rpg-dice-roller/types/exceptions/DieActionValueError.d.ts:12:22 - error TS2304: Cannot find name 'StandardDice'.
12 constructor(die: StandardDice, action?: string | null | undefined);
~~~~~~~~~~~~
node_modules/@dice-roller/rpg-dice-roller/types/exceptions/DieActionValueError.d.ts:14:10 - error TS2304: Cannot find name 'StandardDice'.
14 die: StandardDice;
~~~~~~~~~~~~
node_modules/@dice-roller/rpg-dice-roller/types/modifiers/CriticalSuccessModifier.d.ts:19:31 - error TS2304: Cannot find name 'ComparePoint'.
19 constructor(comparePoint: ComparePoint);
~~~~~~~~~~~~
node_modules/@dice-roller/rpg-dice-roller/types/modifiers/Modifier.d.ts:39:18 - error TS2304: Cannot find name 'RollResults'.
39 run(results: RollResults, _context: StandardDice | RollGroup): RollResults;
~~~~~~~~~~~
node_modules/@dice-roller/rpg-dice-roller/types/modifiers/Modifier.d.ts:39:41 - error TS2304: Cannot find name 'StandardDice'.
39 run(results: RollResults, _context: StandardDice | RollGroup): RollResults;
~~~~~~~~~~~~
node_modules/@dice-roller/rpg-dice-roller/types/modifiers/Modifier.d.ts:39:56 - error TS2304: Cannot find name 'RollGroup'.
39 run(results: RollResults, _context: StandardDice | RollGroup): RollResults;
~~~~~~~~~
node_modules/@dice-roller/rpg-dice-roller/types/modifiers/Modifier.d.ts:39:68 - error TS2304: Cannot find name 'RollResults'.
39 run(results: RollResults, _context: StandardDice | RollGroup): RollResults;
~~~~~~~~~~~
node_modules/@dice-roller/rpg-dice-roller/types/modifiers/SortingModifier.d.ts:51:41 - error TS2304: Cannot find name 'StandardDice'.
51 run(results: RollResults, _context: StandardDice | RollGroup): RollResults;
~~~~~~~~~~~~
node_modules/@dice-roller/rpg-dice-roller/types/modifiers/SortingModifier.d.ts:51:56 - error TS2304: Cannot find name 'RollGroup'.
51 run(results: RollResults, _context: StandardDice | RollGroup): RollResults;
~~~~~~~~~
node_modules/@dice-roller/rpg-dice-roller/types/utilities/NumberGenerator.d.ts:26:20 - error TS2304: Cannot find name 'Engine'.
26 browserCrypto: Engine;
~~~~~~
node_modules/@dice-roller/rpg-dice-roller/types/utilities/NumberGenerator.d.ts:27:17 - error TS2304: Cannot find name 'Engine'.
27 nodeCrypto: Engine;
~~~~~~
node_modules/@dice-roller/rpg-dice-roller/types/utilities/NumberGenerator.d.ts:29:17 - error TS2304: Cannot find name 'Engine'.
29 nativeMath: Engine;
~~~~~~
node_modules/@dice-roller/rpg-dice-roller/types/utilities/NumberGenerator.d.ts:64:26 - error TS2304: Cannot find name 'Engine'.
64 constructor(engine?: Engine | {
~~~~~~
Found 17 errors in 7 files.
Errors Files
2 node_modules/@dice-roller/rpg-dice-roller/types/dice/FudgeDice.d.ts:18
2 node_modules/@dice-roller/rpg-dice-roller/types/dice/PercentileDice.d.ts:17
2 node_modules/@dice-roller/rpg-dice-roller/types/exceptions/DieActionValueError.d.ts:12
1 node_modules/@dice-roller/rpg-dice-roller/types/modifiers/CriticalSuccessModifier.d.ts:19
4 node_modules/@dice-roller/rpg-dice-roller/types/modifiers/Modifier.d.ts:39
2 node_modules/@dice-roller/rpg-dice-roller/types/modifiers/SortingModifier.d.ts:51
4 node_modules/@dice-roller/rpg-dice-roller/types/utilities/NumberGenerator.d.ts:26
I also forgot to mention that the test file is just called test.ts which then gets transpiled to test.js. The generated code is still valid so the errors aren't critical.
Output after executing tsc:
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const rpg_dice_roller_1 = require("@dice-roller/rpg-dice-roller");
const roller = new rpg_dice_roller_1.DiceRoll("6d6");
console.log(roller.toString());
I've submitted a PR with partial fixes for this.
There may be a better way to handle this, but the problem is the seven files above reference types in the JS docs, but when the TypeScript definitions are generated they're not getting resolved/imported.
Two files still have issues:
For DieActionValueError StandardDice
is referenced in the docs, but not imported.
For Modifier RollGroup
, RollResults
, and StandardDice
are referenced in the docs, but are unknown.
For both of these ESLint errors on a detected dependency cycle.
Well drat. I just started a new project that uses this and just ran into these issues again ... :|
Describe the bug Some of the type definitions seems to be faulty or incomplete.
To Reproduce Steps to reproduce the behaviour:
npm i typescript --save-dev && npx tsc --init
)npm install @dice-roller/rpg-dice-roller
)skipLibCheck
to false in tsconfig.jsonExpected behaviour No type errors show up.
Code snippet
Environment: