Skip to content

Commit

Permalink
Remove /// <reference types='ember-sources/types
Browse files Browse the repository at this point in the history
  • Loading branch information
NullVoxPopuli committed Jan 22, 2024
1 parent 503d249 commit 4c31dac
Show file tree
Hide file tree
Showing 3 changed files with 370 additions and 6 deletions.
10 changes: 4 additions & 6 deletions addon/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,14 @@
],
"repository": "https://github.com/ember-cli/ember-page-title",
"scripts": {
"build": "concurrently 'npm:build:*'",
"build:js": "rollup --config",
"build:types": "glint --declaration",
"build": "rollup --config",
"lint": "concurrently 'npm:lint:*(!fix)' --names 'lint:'",
"lint:fix": "concurrently 'npm:lint:*:fix' --names 'fix:'",
"lint:js": "eslint . --cache",
"lint:js:fix": "eslint . --fix",
"lint:types": "glint --declaration",
"prepack": "rollup --config",
"start": "concurrently 'npm:start:*'",
"start:js": "rollup --config --watch --no-watch.clearScreen",
"start:types": "glint --declaration --watch"
"start": "rollup --config --watch --no-watch.clearScreen"
},
"dependencies": {
"@embroider/addon-shim": "^1.8.7",
Expand Down Expand Up @@ -90,6 +86,8 @@
"eslint-plugin-jsonc": "^2.11.2",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^5.1.2",
"execa": "^8.0.1",
"fix-bad-declaration-output": "^1.0.1",
"npm-run-all": "^4.1.5",
"prettier": "^3.1.1",
"rollup": "^4.9.1",
Expand Down
27 changes: 27 additions & 0 deletions addon/rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { babel } from '@rollup/plugin-babel';
import { Addon } from '@embroider/addon-dev/rollup';
import { execaCommand } from 'execa';

const addon = new Addon({
srcDir: 'src',
Expand Down Expand Up @@ -41,5 +42,31 @@ export default {

// Remove leftover build artifacts when starting a new build.
addon.clean(),

{
name: 'fix-bad-declaration-output',
closeBundle: async () => {
/**
* Generate the types (these include /// <reference types="ember-source/types"
* but our consumers may not be using those, or have a new enough ember-source that provides them.
*/
console.log('Building types');
await execaCommand(`pnpm glint --declaration`, { stdio: 'inherit' });
/**
* https://github.com/microsoft/TypeScript/issues/56571#
* README: https://github.com/NullVoxPopuli/fix-bad-declaration-output
*/
console.log('Fixing types');
await execaCommand(
`pnpm fix-bad-declaration-output declarations/**/*.d.ts`,
{
stdio: 'inherit',
},
);
console.log(
'⚠️ Dangerously (but neededly) fixed bad declaration output from typescript',
);
},
},
],
};
Loading

0 comments on commit 4c31dac

Please sign in to comment.