Skip to content

Commit

Permalink
Merge pull request #5583 from nextcloud-libraries/fix/types
Browse files Browse the repository at this point in the history
fix: Adjust Typescript definition export
  • Loading branch information
susnux authored May 14, 2024
2 parents 77297ab + 46bf2e1 commit c449d82
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 10 deletions.
1 change: 1 addition & 0 deletions cypress/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"extends": "../tsconfig.json",
"exclude": [],
"include": ["./**/*.ts"],
"compilerOptions": {
"rootDir": "..",
Expand Down
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,27 @@
"require": "./dist/index.cjs"
},
"./dist/Components/*.js": {
"types": "./dist/components/*/index.d.ts",
"import": "./dist/Components/*.mjs",
"require": "./dist/Components/*.cjs"
},
"./dist/Directives/*.js": {
"types": "./dist/directives/*/index.d.ts",
"import": "./dist/Directives/*.mjs",
"require": "./dist/Directives/*.cjs"
},
"./dist/Functions/*.js": {
"types": "./dist/functions/*/index.d.ts",
"import": "./dist/Functions/*.mjs",
"require": "./dist/Functions/*.cjs"
},
"./dist/Mixins/*.js": {
"types": "./dist/mixins/*/index.d.ts",
"import": "./dist/Mixins/*.mjs",
"require": "./dist/Mixins/*.cjs"
},
"./dist/Composables/*.js": {
"types": "./dist/composables/*/index.d.ts",
"import": "./dist/Composables/*.mjs",
"require": "./dist/Composables/*.cjs"
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/NcButton/NcButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ export default defineComponent({
},
ncPopoverTriggerAttrs() {
return this.getNcPopoverTriggerAttrs()
return (this.getNcPopoverTriggerAttrs as () => Record<string, string|undefined>)()
},
},
Expand Down
2 changes: 1 addition & 1 deletion tests/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"compilerOptions": {
"rootDir": ".."
},
"include": ["./**/*.ts"],
"exclude": [],
}
12 changes: 6 additions & 6 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{
"extends": "@vue/tsconfig/tsconfig.json",
"include": ["./src/**/*.ts", "./src/**/*.vue", "**/*.ts"],
"exclude": ["./src/**/*.cy.ts"],
"include": ["./src/**/*.js","./src/**/*.ts", "./src/**/*.vue", "**/*.ts"],
"exclude": ["./src/**/*.cy.ts", "cypress", "tests"],
"compilerOptions": {
"allowJs": true,
"allowSyntheticDefaultImports": true,
"moduleResolution": "Bundler",
"target": "ESNext",
"module": "ESNext",
"declaration": true,
"strict": true,
"moduleResolution": "Bundler",
"noImplicitAny": false,
"outDir": "./dist",
"rootDir": "./src",
"rootDir": ".",
"strict": true,
"noEmit": true,
},

"vueCompilerOptions": {
Expand Down
13 changes: 11 additions & 2 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { defineConfig } from 'vite'

import md5 from 'md5'

import l10nPlugin from './build/l10n-plugin.mts'
import l10nPlugin from './build/l10n-plugin.mjs'

const appVersion = JSON.stringify(process.env.npm_package_version || 'nextcloud-vue')
const versionHash = md5(appVersion).slice(0, 7) as string
Expand Down Expand Up @@ -94,6 +94,15 @@ export default defineConfig((env) => {
const createConfig = createLibConfig(entryPoints, {
// Add our overrides to the config
config: overrides,
// Only create declarations for source files
DTSPluginOptions: {
include: ['src/**/*.ts', 'src/**/*.js', 'src/**/*.vue'],
compilerOptions: {
declaration: true,
rootDir: 'src',
noEmit: false,
},
},
// By default all dependencies are external, but no path imports
nodeExternalsOptions: {
// Packages with paths imports should be added here to mark them as external as well
Expand All @@ -104,7 +113,7 @@ export default defineConfig((env) => {
// For backwards compatibility we include the css within the js files
inlineCSS: true,
// Build CommonJS files for backwards compatibility
libraryFormats: ['es', 'cjs'],
libraryFormats: ['cjs', 'es'],
replace: {
PRODUCTION: JSON.stringify(env.mode === 'production'),
SCOPE_VERSION,
Expand Down

0 comments on commit c449d82

Please sign in to comment.