briancbarrow / vue-component-library-2023

25 stars 9 forks source link

Not support typescript #3

Open hamedg68 opened 9 months ago

hamedg68 commented 9 months ago

If I use this lib in Vue + Vite + typescript project, there is an error when use it Could not find a declaration file for module

aalto95 commented 9 months ago

same for me image

chou1213 commented 7 months ago

reference:https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-7.html#packagejson-exports-imports-and-self-referencing

In the new version of TypeScript, the types field in the package.json root structure is no longer used. Instead, you need to add the types field in exprots

Like this: "exports": { ".": { "import": "./dist/vue3-component-lib.js", "require": "./dist/vue3-component-lib.umd.cjs", "types": "./dist/index.d.ts" }, "./style.css": "./dist/style.css" },

classicalguss commented 6 months ago

reference:https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-7.html#packagejson-exports-imports-and-self-referencing

In the new version of TypeScript, the types field in the package.json root structure is no longer used. Instead, you need to add the types field in exprots

Like this: "exports": { ".": { "import": "./dist/vue3-component-lib.js", "require": "./dist/vue3-component-lib.umd.cjs", "types": "./dist/index.d.ts" }, "./style.css": "./dist/style.css" },

I tried this, and same thing. I still get an error. Here is my package.json

{
    "name": "vue-bayt-ui",
    "private": false,
    "version": "0.0.5",
    "type": "module",
    "files": [
        "dist",
        "src/components"
    ],
    "exports": {
        ".": {
            "import": {
                "types": "./types/esm/index.d.ts",
                "default": "./esm/vue-bayt-ui.js"
            },
            "require": {
                "types": "./types/commonjs/index.d.cts",
                "default": "./commonjs/vue-bayt-ui.cjs"
            }
        }
    },
    "types": "./types/index.d.ts",
    "main": "./commonjs/vue-bayt-ui.cjs",
    "scripts": {
        "dev": "vite",
        "build": "vue-tsc --emitDeclarationOnly && vite build",
        "types": "vue-tsc ",
        "preview": "vite preview"
    },
    "peerDependencies": {
        "vue": "^3.3.11"
    },
    "devDependencies": {
        "@types/node": "^20.10.5",
        "@vitejs/plugin-vue": "^4.5.2",
        "path": "^0.12.7",
        "typescript": "^5.2.2",
        "vite": "^5.0.8",
        "vite-plugin-dts": "^3.6.4",
        "vue-tsc": "^1.8.25"
    }
}
Juan-Pablo-Spiatta commented 5 months ago

I had the same issue with TypeScript, and what I did was to add a 'type' within 'exports' with the path to the index.d.ts file located inside the 'dist' folder. In my particular case, it is inside 'dist/src'.

package.json

"exports": {
    ".": {
      "import": "./dist/jps-library-components.js",
      "require": "./dist/jps-library-components.umd.cjs",
      "types": "./dist/src/index.d.ts"
    },
    "./style.css": "./dist/style.css"
},

image

salman-ar-sar commented 2 months ago

I am getting the following error when importing my component in a client project.

Definitions of the following identifiers conflict with those in another file: __VLS_IntrinsicElements, __VLS_Element, __VLS_GlobalComponents, __VLS_IsAny, __VLS_PickNotAny, __VLS_intrinsicElements, __VLS_SelfComponent, __VLS_WithComponent, __VLS_FillingEventArg_ParametersLength, __VLS_FillingEventArg, __VLS_FunctionalComponentProps, __VLS_AsFunctionOrAny, __VLS_UnionToIntersection, __VLS_OverloadUnionInner, __VLS_OverloadUnion, __VLS_ConstructorOverloads, __VLS_NormalizeEmits, __VLS_PrettifyGlobal

Any idea why?