Skip to content

Webpack build with typescript fails on the route.ts file #1071

@ArtemK123

Description

@ArtemK123

Package(s)

  • router

Describe the bug
I have tried to use your lib in my project, but it causes the build to fail. I am using Webpack5 with typescript, and during the build, the ts-loader plugin from Webpack fails because of invalid type casts in the route.ts file from your lib.

The error is following:

ERROR in D:\Developing\PolytechWebThings\src\Web\ClientApp\node_modules\@profiscience\knockout-contrib-router\src\route.ts
161:4-55
[tsl] ERROR in D:\Developing\PolytechWebThings\src\Web\ClientApp\node_modules\@profiscience\knockout-contrib-router\src\route.ts(161,5)
  TS2322: Type 'RouteConfig' is not assignable to type 'NativeRouteConfig[]'.
  Type 'string' is not assignable to type 'NativeRouteConfig[]'.
ts-loader-default_e3b0c44298fc1c14 

To Reproduce
Url to my project - > https://github.com/ArtemK123/PolytechWebThings

  1. Clone my repo
  2. Go to "/src/Web/ClientApp"
  3. Install the latest version of the router lib (2.1.5 at the moment of writing): npm install @profiscience/knockout-contrib-router
  4. Try to add an import in some .ts file. I have used index.ts for this. Add the following import there import { Route, Router } from '@profiscience/knockout-contrib-router';
  5. Run webpack build via npm run build

Expected behavior
Webpack build is finished successfully

Desktop (please complete the following information):

  • Windows 20H2
  • node v12.17.0
  • The build was executed from the cmd

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions