svelte-material-ui icon indicating copy to clipboard operation
svelte-material-ui copied to clipboard

Svelte data-table doesn't build in typescript with webpack

Open Chase22 opened this issue 2 years ago • 1 comments

Describe the bug When trying to build svelte with webpack, having used the webpack-template the build fails in the data-table package. Using the dev server works without problems

[...]
ERROR in webapp/node_modules/@smui/data-table/src/Row.types.ts
11:12-18
[tsl] ERROR in webapp/node_modules/@smui/data-table/src/Row.types.ts(11,13)
      TS2503: Cannot find namespace 'svelte'.

ERROR in webapp/node_modules/@smui/data-table/src/Pagination.types.ts
1:27-48
[tsl] ERROR in webapp/node_modules/@smui/data-table/src/Pagination.types.ts(1,28)
      TS2307: Cannot find module './Pagination.svelte' or its corresponding type declarations.

ERROR in webapp/node_modules/@smui/data-table/src/Pagination.types.ts
11:12-18
[tsl] ERROR in webapp/node_modules/@smui/data-table/src/Pagination.types.ts(11,13)
      TS2503: Cannot find namespace 'svelte'.

ERROR in webapp/node_modules/@smui/data-table/src/Pagination.types.ts
16:8-14
[tsl] ERROR in webapp/node_modules/@smui/data-table/src/Pagination.types.ts(16,9)
      TS2503: Cannot find namespace 'svelte'.

package.json

{
  "name": "svelte-app",
  "version": "1.0.0",
  "license": "GPL-3.0-or-later",
  "devDependencies": {
    "@openapitools/openapi-generator-cli": "^2.4.26",
    "@smui/common": "^6.0.0-beta.15",
    "@smui/select": "^6.0.0-beta.15",
    "@smui/top-app-bar": "^6.0.0-beta.15",
    "@smui/data-table": "^6.0.0-beta.15",
    "@smui/icon-button": "^6.0.0-beta.15",
    "smui-theme": "^6.0.0-beta.15",
    "@tsconfig/svelte": "^3.0.0",
    "@types/node": "^17.0.21",
    "cross-env": "^7.0.3",
    "css-loader": "^6.7.1",
    "mini-css-extract-plugin": "^2.6.0",
    "prettier": "^2.5.1",
    "svelte": "^3.31.2",
    "svelte-check": "^2.4.5",
    "svelte-loader": "^3.1.2",
    "svelte-preprocess": "^4.10.4",
    "ts-loader": "^9.2.8",
    "tslib": "^2.3.1",
    "typescript": "^4.6.2",
    "webpack": "^5.70.0",
    "webpack-cli": "^4.9.2",
    "webpack-dev-server": "^4.7.4"
  },
  "scripts": {
    "build": "cross-env NODE_ENV=production webpack",
    "dev": "webpack serve --content-base public",
    "validate": "svelte-check",
    "prepare": "mkdir -p public/build && npm run smui-theme-light && npm run smui-theme-dark && npm run generate-client",
    "smui-theme-light": "smui-theme compile public/build/smui.css -i src/ui/theme",
    "smui-theme-dark": "smui-theme compile public/build/smui-dark.css -i src/ui/theme/dark",
    "generate-client": "openapi-generator-cli generate -i ../../apispec.yaml -o src/generated -g typescript-axios"
  },
  "dependencies": {
    "axios": "^0.26.0",
    "svelte-navigator": "^3.1.5"
  }
}

Chase22 avatar Mar 12 '22 19:03 Chase22

I found that updating the file extension from .types.ts to .types.d.ts in the files complaining will solve the issue locally. Obviously it's not a real fix, but it should be easy enough to update in a small PR

astev89 avatar May 24 '22 14:05 astev89