Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exports for typescript may not be correct #32

Open
benknoble opened this issue Aug 14, 2024 · 0 comments · May be fixed by #33
Open

Exports for typescript may not be correct #32

benknoble opened this issue Aug 14, 2024 · 0 comments · May be fixed by #33

Comments

@benknoble
Copy link

Compiler Error

src/main.ts:5:19 - error TS7016: Could not find a declaration file for module 'piscina-locks'. '$HOME/code/temp/vue-project/node_modules/piscina-locks/dist/esm-wrapper.mjs' implicitly has an 'any' type.
  There are types at '$HOME/code/temp/vue-project/node_modules/piscina-locks/dist/lib/index.d.ts', but this result could not be resolved when respecting package.json "exports". The 'piscina-locks' library may need to update its package.json or typings.

5 import locks from 'piscina-locks'

Possible solution

It looks like the types line in package.json might also need to be in the exports spec, but I'm out of my depth here.

Workaround

Use // @ts-expect-error to ignore this particular error until this issue is resolved.

MRE

# yarn create vue
# some prompts translated from French, so may not line up exactly with what you see
✔ Name of project: … vue-project
✔ Add TypeScript? … Yes
✔ Add JSX support? … No
✔ Add Vue Router…? … No
✔ Add Pinia? … Yes
✔ Add Vitest? … Yes
✔ Add e2e test library? › No
✔ Add ESLint? … Yes
✔ Add Prettier? … Yes
✔ Add the extension Vue DevTools 7? (experimental) … No

# cd vue-project
# yarn add -D piscina-locks
# edit src/main.ts
# nl !$
     1	import './assets/main.css'
      	
     2	import { createApp } from 'vue'
     3	import { createPinia } from 'pinia'
     4	import locks from 'piscina-locks'
     5	import App from './App.vue'
      	
     6	const app = createApp(App)
      	
     7	app.use(createPinia())
      	
     8	app.mount('#app')
# yarn build
# ^--- this is where the compiler error shows up

Here are the various tsconfig files added to the MRE, in case that helps:

# tsconfig.app.json
     1	{
     2	  "extends": "@vue/tsconfig/tsconfig.dom.json",
     3	  "include": ["env.d.ts", "src/**/*", "src/**/*.vue"],
     4	  "exclude": ["src/**/__tests__/*"],
     5	  "compilerOptions": {
     6	    "composite": true,
     7	    "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
      	
     8	    "baseUrl": ".",
     9	    "paths": {
    10	      "@/*": ["./src/*"]
    11	    }
    12	  }
    13	}
# tsconfig.json
     1	{
     2	  "files": [],
     3	  "references": [
     4	    {
     5	      "path": "./tsconfig.node.json"
     6	    },
     7	    {
     8	      "path": "./tsconfig.app.json"
     9	    },
    10	    {
    11	      "path": "./tsconfig.vitest.json"
    12	    }
    13	  ]
    14	}
# tsconfig.node.json
     1	{
     2	  "extends": "@tsconfig/node20/tsconfig.json",
     3	  "include": [
     4	    "vite.config.*",
     5	    "vitest.config.*",
     6	    "cypress.config.*",
     7	    "nightwatch.conf.*",
     8	    "playwright.config.*"
     9	  ],
    10	  "compilerOptions": {
    11	    "composite": true,
    12	    "noEmit": true,
    13	    "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
      	
    14	    "module": "ESNext",
    15	    "moduleResolution": "Bundler",
    16	    "types": ["node"]
    17	  }
    18	}
# tsconfig.vitest.json
     1	{
     2	  "extends": "./tsconfig.app.json",
     3	  "exclude": [],
     4	  "compilerOptions": {
     5	    "composite": true,
     6	    "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.vitest.tsbuildinfo",
      	
     7	    "lib": [],
     8	    "types": ["node", "jsdom"]
     9	  }
    10	}
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 a pull request may close this issue.

1 participant