-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prove out basic stable type generation
This isn't remotely ready for primetime, but it does prove out the basic viability of @chadhietala's suggestion that we may not need to fix all the circularities before we can publish. We in fact can just publish as is: none of the circularities are *hard* blockers, at least for *this* part of the effort (though they will be for getting docs published with these as the source of truth). The things we will need to do to be able to execute the rest of the way on this, given our goals: - Fix a couple cases where we are using private names in public types, specifically around the `OWNER` from `@glimmer/owner`. - Put the hacky `generate-tsconfigs.mjs` script somewhere besides the root, expand its capabilities to include wrapping generated modules in a `declare module` statement and running Prettier on the result, and rename it accordingly. - Land @wagenet's in-progress PR (#20175) to convert the `ember` package to TS so we can publish types for it, which will unblock some of the other Ember packages as well. - Properly exclude the parts of Ember's APIs we *don't* want to be publishing (all the purely-internal and private stuff).
- Loading branch information
1 parent
d61d713
commit 9812772
Showing
6 changed files
with
91 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/usr/bin/env node | ||
// @ts-check | ||
|
||
import fs from 'node:fs'; | ||
import { join } from 'node:path'; | ||
import { cwd } from 'node:process'; | ||
|
||
const TYPES_DIR = join(cwd(), 'types', 'stable'); | ||
|
||
fs.writeFileSync( | ||
join(TYPES_DIR, 'tsconfig.json'), | ||
`{ | ||
"extends": "@tsconfig/ember/tsconfig.json", | ||
"compilerOptions": { | ||
"baseUrl": "." | ||
} | ||
} | ||
` | ||
); | ||
|
||
fs.writeFileSync( | ||
join(TYPES_DIR, 'ember', 'tsconfig.json'), | ||
`{ | ||
"extends": "../tsconfig.json" | ||
} | ||
` | ||
); | ||
|
||
const NAMESPACE_CONFIG = `{ | ||
"extends": "../../tsconfig.json" | ||
} | ||
`; | ||
|
||
[join(TYPES_DIR, '@ember'), join(TYPES_DIR, '@glimmer')] | ||
.flatMap((dirName) => | ||
fs.readdirSync(dirName, { withFileTypes: true }).map((dirent) => ({ dirName, dirent })) | ||
) | ||
.filter(({ dirent }) => dirent.isDirectory()) | ||
.forEach(({ dirName, dirent: { name } }) => { | ||
let fileName = join(dirName, name, 'tsconfig.json'); | ||
// eslint-disable-next-line no-console, no-undef | ||
console.log(`printing to ${fileName}`); | ||
try { | ||
fs.writeFileSync(fileName, NAMESPACE_CONFIG); | ||
} catch (e) { | ||
// eslint-disable-next-line no-console, no-undef | ||
console.error(`error writing to ${fileName}: ${e}`); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"$schema": "https://json.schemastore.org/tsconfig", | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"noEmit": false, | ||
"declaration": true, | ||
"emitDeclarationOnly": true, | ||
"declarationMap": true, | ||
"declarationDir": "types/stable" | ||
}, | ||
"include": [ | ||
// Note: these will also pull on all their transitive dependencies, so we | ||
// will end up publishing the (private!) types for packages not named here | ||
// until we update the actual internals to avoid referencing them! | ||
"packages/@ember/**/*", | ||
"packages/ember/**/*", | ||
"packages/@glimmer/**/*" | ||
], | ||
"exclude": [ | ||
"dist", | ||
"node_modules", | ||
"tmp", | ||
"types", | ||
"packages/ember-template-compiler", | ||
"packages/ember-testing", | ||
"packages/internal-test-helpers" | ||
] | ||
} |