-
-
Notifications
You must be signed in to change notification settings - Fork 894
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Leverage TypeScript project references #838
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
coverage/ | ||
node_modules/ | ||
*.d.ts.map | ||
*.d.ts | ||
types/ | ||
*.log | ||
*.tsbuildinfo | ||
.DS_Store | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export type {ExtraProps} from 'hast-util-to-jsx-runtime' | ||
export { | ||
type AllowElement, | ||
type Components, | ||
type Options, | ||
type UrlTransform, | ||
defaultUrlTransform, | ||
default | ||
} from './index.js' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this should be an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We’re still not compiling anything to JavaScript with these changes. TypeScript is actually really good at generating We could indeed write There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it’s sad that we can no longer have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The entry point of a package is While a file named |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -138,7 +138,7 @@ const deprecations = [ | |
* @returns {ReactElement} | ||
* React element. | ||
*/ | ||
export function Markdown(options) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this change can be discarded, with the change in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No. |
||
export default function Markdown(options) { | ||
const allowedElements = options.allowedElements | ||
const allowElement = options.allowElement | ||
const children = options.children || '' | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,12 +69,13 @@ | |
], | ||
"sideEffects": false, | ||
"type": "module", | ||
"exports": "./index.js", | ||
"exports": { | ||
"types": "./types/exports.d.ts", | ||
"default": "./lib/index.js" | ||
}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it correct that the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The In a TypeScript project, the source code is written in a When using types in JSDoc, the source file is the runtime file. Because you’re supposed to separate the generated output from the source directory, we need to use package exports to point the |
||
"files": [ | ||
"lib/", | ||
"index.d.ts.map", | ||
"index.d.ts", | ||
"index.js" | ||
"types/" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does the generated folder structure look like? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the folder structure after running
As you can see there are 2 generated files/folders:
There’s now a clear distinction between generated files and source files. There’s no more confusion for neither TypeScript, editor tooling, or authors. The |
||
], | ||
"dependencies": { | ||
"@types/hast": "^3.0.0", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"compilerOptions": { | ||
"checkJs": true, | ||
"customConditions": ["development"], | ||
"exactOptionalPropertyTypes": true, | ||
"module": "node16", | ||
"strict": true, | ||
"target": "es2022" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"extends": "./tsconfig.base.json", | ||
"compilerOptions": { | ||
"composite": true, | ||
"declaration": true, | ||
"declarationMap": true, | ||
"emitDeclarationOnly": true, | ||
"lib": ["dom", "es2022"], | ||
"outDir": "types/", | ||
"rootDir": "lib/", | ||
"target": "es2022", | ||
"types": [] | ||
}, | ||
"include": ["lib/"] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,11 @@ | ||
{ | ||
"extends": "./tsconfig.base.json", | ||
"compilerOptions": { | ||
"checkJs": true, | ||
"customConditions": ["development"], | ||
"declarationMap": true, | ||
"declaration": true, | ||
"emitDeclarationOnly": true, | ||
"exactOptionalPropertyTypes": true, | ||
"jsx": "preserve", | ||
"lib": ["dom", "es2022"], | ||
"module": "node16", | ||
"strict": true, | ||
"target": "es2022" | ||
"lib": ["es2022"], | ||
"noEmit": true, | ||
"types": ["node"] | ||
}, | ||
"exclude": ["coverage/", "node_modules/"], | ||
"include": ["**/*.js", "**/*.jsx", "lib/complex-types.d.ts"] | ||
"exclude": ["coverage/", "lib/", "node_modules/"], | ||
"references": [{"path": "./tsconfig.build.json"}] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be possible to do
Markdown as default
, then you don‘t need the change inlib/index.js
hereThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No.
lib/index.js
exports the actual runtime package values.exports.ts
describes the package values. These exports must be in sync. Sincelib/index.js
has a default export, so shouldexports.ts
.I would love to change the export of this package to a named one, but that’s out of scope and a breaking change.