diff --git a/generators/app/templates/_package.json b/generators/app/templates/_package.json index 293e91f..902eaa2 100644 --- a/generators/app/templates/_package.json +++ b/generators/app/templates/_package.json @@ -6,7 +6,8 @@ "main": "<% if ( sassModule ) { %>_index.scss<% } else if ( cssModule ) { %>index.css<% } else { %><% if ( transpile ) { %><% if ( bundleCjs ) { %>cjs/<% } else { %>esm/<% } %><% } %>index.js<% } %>", "module": "<% if ( transpile ) { %>esm/<% } %>index.js", "exports": { - ".": {<% if ( browserModule && styles || sassModule || cssModule ) { %><% if ( sassModule ) { %> + ".": {<% if ( typescript ) { %> + "types": "<% if ( transpile ) { %>esm/<% } %>index.d.ts",<% } %><% if ( browserModule && styles || sassModule || cssModule ) { %><% if ( sassModule ) { %> "sass": "./_index.scss",<% } %> "style": "./<% if ( sassModule ) { %>_index.scss<% } else if ( cssModule ) { %>index.css<% } else { %><% if ( transpile ) { %>dist/<% } %>index.css<% } %>",<% } %> "import": "./<% if ( transpile ) { %>esm/<% } %>index.js"<% if ( bundleCjs ) { %>, @@ -143,7 +144,7 @@ "eslint-plugin-html": "^6.0.0", "rollup-plugin-svelte": "^7.2.0", "svelte": "^2.16.1"<% } %><% if ( typescript ) { %>, - "typescript": "^4.3.5", + "typescript": "^5.4.3", "cpy": "^8.1.2", "execa": "^5.1.1",<% if ( !transpile && typescriptMode === 'full' && (!browserModule || (browserModule && integrationTests)) ) { %> "ts-node": "^10.1.0",<% } %><% if ( browserModule && usesHtmlFixtures ) { %> @@ -167,6 +168,5 @@ "bugs": { "url": "https://<%= gitRepo.host %>/<%= gitRepo.repository %>/issues" }, - "homepage": "https://<%= gitRepo.host %>/<%= gitRepo.repository %>#readme"<% if ( typescript ) { %>, - "types": "<% if ( transpile ) { %>esm/<% } %>index.d.ts"<% } %> + "homepage": "https://<%= gitRepo.host %>/<%= gitRepo.repository %>#readme" } diff --git a/generators/app/templates/tsconfig.json b/generators/app/templates/tsconfig.json index 8151479..c03b0c5 100644 --- a/generators/app/templates/tsconfig.json +++ b/generators/app/templates/tsconfig.json @@ -1,12 +1,13 @@ { "compilerOptions": { - "target": "ESNext", - "module": "ESNext", - "lib": ["ESNext"<% if ( browserModule ) { %>, "DOM"<% } %>], - "moduleResolution": "node", + "target": "ES2022", + "module": "node16", + "lib": ["ES2022"<% if ( browserModule ) { %>, "DOM"<% } %>], + "moduleResolution": "node16", + "moduleDetection": "force", "allowSyntheticDefaultImports": true, "esModuleInterop": true, - "resolveJsonModule": true, + "resolveJsonModule": false, "noEmit": true, "newLine": "lf", "strict": true, diff --git a/test/index.js b/test/index.js index 25add68..b8ad0de 100644 --- a/test/index.js +++ b/test/index.js @@ -1470,12 +1470,16 @@ describe('TypeScript, with comments', function () { it('should fill package.json with correct information', function () { assert.jsonFileContent('package.json', { - types: 'esm/index.d.ts', + exports: { + '.': { + types: 'esm/index.d.ts' + } + }, scripts: { 'lint:types': 'tsc' }, devDependencies: { - 'typescript': '^4.3.5', + 'typescript': '^5.4.3', '@types/node': '^16.3.0', '@types/mocha': '^10.0.6' }