-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
[dev-2.0] Fix optional and rest parameters in TypeScript class method declarations #7863
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
Open
SoundOfScooting
wants to merge
2
commits into
processing:dev-2.0
Choose a base branch
from
SoundOfScooting:fix-ts-optional
base: dev-2.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@limzykenneth I think you updated type exporting in package.json last, does this look OK to you?
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.
It might be neccessary the update all the exports fields and additionally add the field
"type": "module"
to package.json. This affects the esm build not the iife. By using the exports conditiondefault
the files will be interpreted as .cjs files which might also result in conflicts with the type definitions. I'll doublecheck latersee
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.
The link you posted says
default
"Can be a CommonJS or ES module file".Also, forgot to mention this here in the PR, but the other
index.js
exports fields don't have correspondingindex.d.ts
declaration files to point to. I think it's because those files don't have any doc comments themselves.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.
I'm wondering if this should be part of a separate issue.
Please correct me if I'm wrong because I'm still in the process of wrapping my head around
generate-types.mjs
and reading relevant issues.I'm using publint and arethetypeswrong as a reference. Generally these tools are made to check node.js packages therefore only the
bundler
module resolution should be of interest. Nonetheless there are some resolution errors within the declaration files. E.g.:/// <reference path="./p5.d.ts" />
import { Color } from '../color/p5.Color';
(There are similar issues in other .d.ts files) I assume it's due to circular dependencies (as stated in the rollup build logs)Regarding the conditional exports:
"./friendlyErrors": "./dist/core/friendlyErrors/index.js",
can't be resolved. The correct file path would be"./dist/core/friendly_errors/index.js"
Yes the link I posted refers to node's module resolution algorithm whereas the majority of the p5.js endusers and consumers will or should use a bundler to resolve modules. So the main take away of this link is:
https://nodejs.org/api/packages.html#introduction_1
Uh oh!
There was an error while loading. Please reload this page.
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.
I agree, it probably makes more sense as a separate issue then. I thought the problem would only require a small change so I was hoping to get it merged with the overload fix at the same time. If requested I will remove the change from this PR for a future one.
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.
I'm guessing for the other exports we don't have a setup for their types just yet that would make sense? We don't need it now as the full ESM modular use is not at a stage where I want to push it publicly yet, but we can start thinking about how it would work.
I'm fully in favor of including
"type": "module"
in package.json and shift any remaining code we have that still uses cjs to ESM, I think dependencies wise it should all support ESM without issue now.