nix-community / yarn2nix

Generate nix expressions from a yarn.lock file [maintainer=???]
GNU General Public License v3.0
123 stars 61 forks source link

tslint and typescript compiler failing #149

Closed purefn closed 4 years ago

purefn commented 4 years ago

I have a TypeScript SPA that I'm trying to get work with mkYarnPackage. The problem I'm running into that I'm unable to figure out is that when running tslint, it gives errors that it does not give when built with plain old yarn. All the errors are of this type Unsafe use of expression of type 'any'..

To see if that was the only problem, I took tslint out of the build pipeline. Now I'm able to get to the point where the typescript compiler is run, but I see errors there too.

portal-client> jest-e2e/jest-e2e.setup.ts:10:1 - error TS2304: Cannot find name 'page'.
portal-client> 10 page.setDefaultNavigationTimeout(0)
portal-client>    ~~~~
portal-client> packages/monorail/src/helpers/hooks.ts:75:34 - error TS2769: No overload matches this call.
portal-client> Overload 1 of 2, '(callback: (...args: any[]) => void, ms: number, ...args: any[]): Timer', gave the following error.
portal-client> Argument of type 'number | null' is not assignable to parameter of type 'number'.
portal-client> Type 'null' is not assignable to type 'number'.
portal-client> Overload 2 of 2, '(handler: TimerHandler, timeout?: number | undefined, ...arguments: any[]): number', gave the following error.
portal-client> Argument of type 'number | null' is not assignable to parameter of type 'number | undefined'.
portal-client> Type 'null' is not assignable to type 'number | undefined'.
portal-client> 75     const id = setInterval(tick, delay)
portal-client>                                     ~~~~~
portal-client> packages/monorail/src/helpers/hooks.ts:114:5 - error TS2322: Type 'Timer' is not assignable to type 'number'.
portal-client> 114     timeoutIdRef.current = setTimeout(callbackRef.current, timeout)
portal-client>         ~~~~~~~~~~~~~~~~~~~~
portal-client> packages/monorail/src/visualComponents/loading/Loading.tsx:2:20 - error TS2307: Cannot find module 'react-lottie'.
portal-client> 2 import Lottie from 'react-lottie'
portal-client>                      ~~~~~~~~~~~~~~
portal-client> packages/monorail/src/visualComponents/tooltips/Tooltip.tsx:11:42 - error TS2307: Cannot find module '@reach/tooltip'.
portal-client> 11 import { useTooltip, TooltipPopup } from '@reach/tooltip'
portal-client>                                             ~~~~~~~~~~~~~~~~
portal-client> src/common/hooks/useInterval.ts:20:5 - error TS2322: Type 'Timer' is not assignable to type 'number'.
portal-client> 20     intervalIdRef.current = setInterval(callbackRef.current, props.interval)
portal-client>        ~~~~~~~~~~~~~~~~~~~~~
portal-client> src/common/monoblocks/networkGraph/cytoscape.styles.helpers.ts:319:33 - error TS2339: Property 'context' does not exist on type 'NodeRequire'.
portal-client> 319 const requireBasePath = require.context(
portal-client>                                     ~~~~~~~
portal-client> src/design/Components/CodeHighlight.tsx:2:31 - error TS7016: Could not find a declaration file for module 'react-syntax-highlighter/prism'. '/build/client/node_modules/react-syntax-highlighter/prism.js' implicitly has an 'any' type.
portal-client> Try `npm install @types/react-syntax-highlighter` if it exists or add a new declaration (.d.ts) file containing `declare module 'react-syntax-highlighter/prism';`
portal-client> 2 import SyntaxHighlighter from 'react-syntax-highlighter/prism'
portal-client>                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
portal-client> src/design/Components/CodeHighlight.tsx:3:26 - error TS7016: Could not find a declaration file for module 'react-syntax-highlighter/styles/prism'. '/build/client/node_modules/react-syntax-highlighter/styles/prism/index.js' implicitly has an 'any' type.
portal-client> Try `npm install @types/react-syntax-highlighter` if it exists or add a new declaration (.d.ts) file containing `declare module 'react-syntax-highlighter/styles/prism';`
portal-client> 3 import { ghcolors } from 'react-syntax-highlighter/styles/prism'
portal-client>                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
portal-client> src/execution/range-status/view/ExecutionRangeStatus.tsx:230:5 - error TS2322: Type 'Timer' is not assignable to type 'number'.
portal-client> 230     _intervalId = setInterval(fetchLiveData, 1000 * 30)
portal-client>         ~~~~~~~~~~~
portal-client> src/range/consoles/interfaces/vmware/VMwareInterface.tsx:384:7 - error TS2322: Type 'Timer' is not assignable to type 'number'.
portal-client> 384       this.connectionAttemptTimeout = setTimeout(() => {
portal-client>           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
portal-client> Found 11 errors.

They all seem to be indicating something is missing in the set up, but I have no idea what that could be. Has anyone run into something like this before using mkYarnPackage/yarn2nix? How might I go about figuring out what is wrong?

purefn commented 4 years ago

This appears to be a problem with the wrong versions of packages appearing in the node_modules created during the nix build. I haven't worked out why some versions are different, but it definitely appears to be the problem. I'll close this and open a separate issue if I can track the problem down to yarn2nix.