single-spa-layout icon indicating copy to clipboard operation
single-spa-layout copied to clipboard

Typescript: Parse5 DefaultTreeDocument not found

Open Khazl opened this issue 2 years ago • 2 comments

Hey, I installed single-spa@beta and single-spa-layout@^2 and see following error:

[dev:server] node_modules/single-spa-layout/dist/types/isomorphic/constructRoutes.d.ts(74,81): error TS2694: Namespace '"/Users/xxx/spa-test/node_modules/@types/parse5/index"' has no exported member 'DefaultTreeDocument'.

So I checked the content of the parse5 and @types/parse5 dependency and I can't find this DefaultTreeDocument anywhere.

It's pretty confusing, because single-spa@^5 with single-spa-layout@^1 also expects this member but doesn't throws an error. Even though both single-spa-layout versions use the same version of parse5.

Is this a known issue or does anyone have an idea what's wrong here?

Khazl avatar Apr 26 '22 11:04 Khazl

Hello, i have same problem here.

I followed this recomendation: https://github.com/single-spa/single-spa-layout/issues/60

Instal yarn add parse5 but is not resolve problem.

Errors Files

     2  node_modules/single-spa-layout/dist/types/browser/constructApplications.d.ts:36
     2  node_modules/single-spa-layout/dist/types/isomorphic/constructRoutes.d.ts:74
     8  node_modules/single-spa-layout/node_modules/single-spa/typings/single-spa.d.ts:1
     4  node_modules/single-spa/typings/single-spa.d.ts:1

Dependencies:

  "dependencies": {
    "@types/jest": "^27.0.1",
    "@types/systemjs": "^6.1.1",
    "@types/webpack-env": "^1.16.2",
    "single-spa": "^5.9.3",
    "single-spa-layout": "^2.1.0"
  },

Output error:

$ tsc
node_modules/single-spa-layout/dist/types/browser/constructApplications.d.ts:36:5 - error TS1170: A computed property name in a type literal must refer to an expression whose type is a literal type or a 'unique symbol' type.

36     [name]: Array<AppRoute>;
       ~~~~~~

node_modules/single-spa-layout/dist/types/browser/constructApplications.d.ts:36:5 - error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.

36     [name]: Array<AppRoute>;
       ~~~~~~

node_modules/single-spa-layout/dist/types/isomorphic/constructRoutes.d.ts:74:81 - error TS2694: Namespace '"/Users/cristoferpereira/Desktop/dev/latam/messaging-container-backoffice-latam-ui/node_modules/parse5/dist/index"' has no exported member 'DefaultTreeDocument'.

74 export type RoutesConfig = InputRoutesConfigObject | Element | import('parse5').DefaultTreeDocument | string;
                                                                                   ~~~~~~~~~~~~~~~~~~~

node_modules/single-spa-layout/dist/types/isomorphic/constructRoutes.d.ts:95:63 - error TS2694: Namespace '"/Users/cristoferpereira/Desktop/dev/latam/messaging-container-backoffice-latam-ui/node_modules/parse5/dist/index"' has no exported member 'Element'.

95 export type ContainerEl = string | Element | import('parse5').Element;
                                                                 ~~~~~~~

node_modules/single-spa-layout/node_modules/single-spa/typings/single-spa.d.ts:1:1 - error TS6200: Definitions of the following identifiers conflict with those in another file: CustomPropsFn, AppProps, ParcelConfig, ParcelProps, ParcelConfigObject, Parcel, LifeCycleFn, LifeCycles, StartOpts, Application, ActivityFn, Activity, RegisterApplicationConfig, SingleSpaCustomEventDetail, NOT_LOADED, LOADING_SOURCE_CODE, NOT_BOOTSTRAPPED, BOOTSTRAPPING, NOT_MOUNTED, MOUNTING, MOUNTED, UPDATING, UNMOUNTING, UNLOADING, SKIP_BECAUSE_BROKEN, LOAD_ERROR, AppError

1 declare module "single-spa" {
  ~~~~~~~

  node_modules/single-spa/typings/single-spa.d.ts:1:1
    1 declare module "single-spa" {
      ~~~~~~~
    Conflicts are in this file.

node_modules/single-spa-layout/node_modules/single-spa/typings/single-spa.d.ts:3:5 - error TS2374: Duplicate index signature for type 'string'.

3     [str: string]: any;
      ~~~~~~~~~~~~~~~~~~~

node_modules/single-spa-layout/node_modules/single-spa/typings/single-spa.d.ts:4:5 - error TS2374: Duplicate index signature for type 'number'.

4     [num: number]: any;
      ~~~~~~~~~~~~~~~~~~~

node_modules/single-spa-layout/node_modules/single-spa/typings/single-spa.d.ts:98:5 - error TS2374: Duplicate index signature for type 'string'.

 98     [key: string]:
        ~~~~~~~~~~~~~~
 99       | "MOUNTED"
    ~~~~~~~~~~~~~~~~~
...
101       | "NOT_LOADED"
    ~~~~~~~~~~~~~~~~~~~~
102       | "SKIP_BECAUSE_BROKEN";
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/single-spa-layout/node_modules/single-spa/typings/single-spa.d.ts:105:5 - error TS2717: Subsequent property declarations must have the same type.  Property '[MOUNTED]' must be of type '[]', but here has type 'string[]'.

105     [MOUNTED]: string[];
        ~~~~~~~~~

  node_modules/single-spa/typings/single-spa.d.ts:105:5
    105     [MOUNTED]: [];
            ~~~~~~~~~
    '[MOUNTED]' was also declared here.

node_modules/single-spa-layout/node_modules/single-spa/typings/single-spa.d.ts:106:5 - error TS2717: Subsequent property declarations must have the same type.  Property '[NOT_MOUNTED]' must be of type '[]', but here has type 'string[]'.

106     [NOT_MOUNTED]: string[];
        ~~~~~~~~~~~~~

  node_modules/single-spa/typings/single-spa.d.ts:106:5
    106     [NOT_MOUNTED]: [];
            ~~~~~~~~~~~~~
    '[NOT_MOUNTED]' was also declared here.

node_modules/single-spa-layout/node_modules/single-spa/typings/single-spa.d.ts:107:5 - error TS2717: Subsequent property declarations must have the same type.  Property '[NOT_LOADED]' must be of type '[]', but here has type 'string[]'.

107     [NOT_LOADED]: string[];
        ~~~~~~~~~~~~

  node_modules/single-spa/typings/single-spa.d.ts:107:5
    107     [NOT_LOADED]: [];
            ~~~~~~~~~~~~
    '[NOT_LOADED]' was also declared here.

node_modules/single-spa-layout/node_modules/single-spa/typings/single-spa.d.ts:108:5 - error TS2717: Subsequent property declarations must have the same type.  Property '[SKIP_BECAUSE_BROKEN]' must be of type '[]', but here has type 'string[]'.

108     [SKIP_BECAUSE_BROKEN]: string[];
        ~~~~~~~~~~~~~~~~~~~~~

  node_modules/single-spa/typings/single-spa.d.ts:108:5
    108     [SKIP_BECAUSE_BROKEN]: [];
            ~~~~~~~~~~~~~~~~~~~~~
    '[SKIP_BECAUSE_BROKEN]' was also declared here.

node_modules/single-spa/typings/single-spa.d.ts:1:1 - error TS6200: Definitions of the following identifiers conflict with those in another file: CustomPropsFn, AppProps, ParcelConfig, ParcelProps, ParcelConfigObject, Parcel, LifeCycleFn, LifeCycles, StartOpts, Application, ActivityFn, Activity, RegisterApplicationConfig, SingleSpaCustomEventDetail, NOT_LOADED, LOADING_SOURCE_CODE, NOT_BOOTSTRAPPED, BOOTSTRAPPING, NOT_MOUNTED, MOUNTING, MOUNTED, UPDATING, UNMOUNTING, UNLOADING, SKIP_BECAUSE_BROKEN, LOAD_ERROR, AppError

1 declare module "single-spa" {
  ~~~~~~~

  node_modules/single-spa-layout/node_modules/single-spa/typings/single-spa.d.ts:1:1
    1 declare module "single-spa" {
      ~~~~~~~
    Conflicts are in this file.

node_modules/single-spa/typings/single-spa.d.ts:3:5 - error TS2374: Duplicate index signature for type 'string'.

3     [str: string]: any;
      ~~~~~~~~~~~~~~~~~~~

node_modules/single-spa/typings/single-spa.d.ts:4:5 - error TS2374: Duplicate index signature for type 'number'.

4     [num: number]: any;
      ~~~~~~~~~~~~~~~~~~~

node_modules/single-spa/typings/single-spa.d.ts:98:5 - error TS2374: Duplicate index signature for type 'string'.

 98     [key: string]:
        ~~~~~~~~~~~~~~
 99       | "MOUNTED"
    ~~~~~~~~~~~~~~~~~
...
101       | "NOT_LOADED"
    ~~~~~~~~~~~~~~~~~~~~
102       | "SKIP_BECAUSE_BROKEN";
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Found 16 errors in 4 files.

Errors  Files
     2  node_modules/single-spa-layout/dist/types/browser/constructApplications.d.ts:36
     2  node_modules/single-spa-layout/dist/types/isomorphic/constructRoutes.d.ts:74
     8  node_modules/single-spa-layout/node_modules/single-

cristofersousa avatar Jul 07 '22 13:07 cristofersousa

I'm also running into similar issues on my root-config when I run yarn build:

package.json:

"devDependencies": {
  "@types/jest": "^28.1.8",
  "@types/react": "^18.0.17",
  "@types/react-dom": "^18.0.6",
  "@types/react-router-dom": "^5.3.3",
  "@types/systemjs": "^6.1.1",
  "@types/webpack-env": "^1.18.0",
},
"dependencies": {
  "react": "^18.2.0",
  "react-dom": "^18.2.0",
  "react-router-dom": "^5.3.0",
  "single-spa": "^5.9.4",
  "single-spa-layout": "^2.1.0"
},

error: root_config_error

mazenchami avatar Aug 30 '22 13:08 mazenchami