Skip to content

Conversation

cgewecke
Copy link
Contributor

@cgewecke cgewecke commented Dec 1, 2021

When you install @setprotocol/set-protocol-v2 from npm, the fixtures etc are currently unusable because TS throws errors like this:

test/manager/baseManagerV2.spec.ts:23:31 - error TS7016: Could not find a declaration file for module '@setprotocol/set-protocol-v2/dist/utils/fixtures/PerpV2Fixture'. '/Users/cgewecke/code/set/set-v2-strategies/node_modules/@setprotocol/set-protocol-v2/dist/utils/fixtures/PerpV2Fixture.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/setprotocol__set-protocol-v2` if it exists or add a new declaration (.d.ts) file containing `declare module '@setprotocol/set-protocol-v2/dist/utils/fixtures/PerpV2Fixture';`

23 import { PerpV2Fixture } from "@setprotocol/set-protocol-v2/dist/utils/fixtures/PerpV2Fixture";
                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

PR:

  • changes the tsconfig to generate source and types maps so imports from node_modules behave as expected
  • copies typechain folder into the dist folder post-build (as part of npm command)
  • updates README with npm package usage example

Have checked that this works by publishing to tag tsdebug

yarn add @setprotocol/set-protocol-v2@tsdebug

... and importing the fixture into the repo we've seen this problem in (on the richard/perp... branch) as below:

import { PerpV2Fixture } from "@setprotocol/set-protocol-v2/dist/utils/fixtures/PerpV2Fixture";
import { getPerpV2Fixture } from "@setprotocol/set-protocol-v2/dist/utils/test";

let perpSetup: PerpV2Fixture;
perpSetup = getPerpV2Fixture(...);

@cgewecke cgewecke force-pushed the chris/fix-ts-publication branch from 37c792b to f15b0a8 Compare December 9, 2021 23:37
@cgewecke cgewecke force-pushed the chris/fix-ts-publication branch from f15b0a8 to 5e0c2e7 Compare December 14, 2021 23:07
@cgewecke cgewecke merged commit fc90605 into master Dec 14, 2021
@cgewecke cgewecke deleted the chris/fix-ts-publication branch December 14, 2021 23:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants