-
Notifications
You must be signed in to change notification settings - Fork 535
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
Deprecate types in tree #23313
base: main
Are you sure you want to change the base?
Deprecate types in tree #23313
Conversation
// The event APIs are known to conflict, and this is intended as the exports via `@fluidframework/core-interfaces` are preferred over the deprecated ones from `@fluidframework/tree`. | ||
// eslint-disable-next-line import/export | ||
Listeners, | ||
// The event APIs are known to conflict, and this is intended as the exports via `@fluidframework/core-interfaces` are preferred over the deprecated ones from `@fluidframework/tree`. | ||
// eslint-disable-next-line import/export | ||
IsListener, | ||
// The event APIs are known to conflict, and this is intended as the exports via `@fluidframework/core-interfaces` are preferred over the deprecated ones from `@fluidframework/tree`. | ||
// eslint-disable-next-line import/export | ||
Listenable, | ||
// The event APIs are known to conflict, and this is intended as the exports via `@fluidframework/core-interfaces` are preferred over the deprecated ones from `@fluidframework/tree`. | ||
// eslint-disable-next-line import/export | ||
Off, | ||
} from "@fluidframework/core-interfaces"; | ||
|
||
export type { isFluidHandle } from "@fluidframework/runtime-utils"; | ||
|
||
// Let the tree package manage its own API surface. | ||
// Note: this only surfaces the `@public, @beta and @alpha` API items from the tree package. | ||
// eslint-disable-next-line no-restricted-syntax, import/no-internal-modules | ||
// This reexports all non-conflicting APIs from `@fluidframework/tree`. The event APIs are known to conflict, and this is intended as the exports via `@fluidframework/core-interfaces` are preferred over the deprecated ones from `@fluidframework/tree`. | ||
// eslint-disable-next-line no-restricted-syntax, import/no-internal-modules, import/export |
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 don't think these comments are sufficient. There will need to be statements about which prevail and why as it is uncommon and plenty of readers won't know the answer. I still don't know the answer.
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.
You could add something like: "When * exports conflict with named exports, the named export is used (and this lint warning is triggered). This allows the non deprecated versions of the events (above as named exports) to replace the deprecated ones from tree."
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.
@CraigMacomber, is there a spec / docs we can reference?
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export says "If there are two wildcard exports statements that implicitly re-export the same name, neither one is re-exported." But I don't see the text about named exports win.
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 found that same document, and was also disappointed due to the same omission so I did some experiments.
I kinda assumed this change would have tests to make sure the exports actually work (compile and work at runtime), I guess it doesn't so those should probably be added.
Note that should the approach taken here not work, blocking the undesired exports with a second wildcard export, then adding them a third time as named exports should be fine according to that document as far as I can tell.
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 tried to understand the actual spec https://tc39.es/ecma262/multipage/ecmascript-language-scripts-and-modules.html#sec-exports but I couldn't figure it out.
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 think perhaps in https://tc39.es/ecma262/multipage/ecmascript-language-scripts-and-modules.html#sec-getexportednames step 8.d.i.1 implies it works as I claimed?
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 had also tried reading the same "sec-exports" page and could not derive the intended/prescribed behavior.
I don't see how second * wildcard would work well/easily. I think it means crafting an extra file in fluid-framework that has just the conflicts, then index exports * from that to cause specific conflicts, then also a named set.
I would favor the other version where there are no conflicts if the spec is complicated or hard to even find. I would not be surprised if some implementation got it wrong. I don't think there will be a lot of maintenance once the structure is in place (with appropriate comments for dev guidance). An alternative would be to explicitly name tree exports like we do for every other package. The other PR gives us compromise version of that option in tree itself - so engineers don't have to hop packages.
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.
(hmm github is not showing me all of the comments in timely fashion - reading other spec soon)
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 think yes it works as you claim, Craig, because all of 7 (IndirectExportEntries) happens before 8. What I don't see in there is support of the MDN note that two wildcards in conflict resolve to none. Per the spec, I would expect the first encountered to win. (Makes me a little concerned about just relying on spec, but not too much.) I am good with either solution with some preference for the explicit handling ourselves.
I think as tree reviewer, Craig, you will get the biggest vote.
Should we choose this and then determine there is a problem, we have an option to fix with the other pattern.
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.
Copilot reviewed 3 out of 3 changed files in this pull request and generated no suggestions.
Comments skipped due to low confidence (5)
packages/framework/fluid-framework/src/index.ts:57
- [nitpick] The comment explaining the ESLint disable directive is quite long and could be split into multiple lines for better readability.
/* eslint-disable import/export -- The event APIs are known to conflict, and this is intended as the exports via `@fluidframework/core-interfaces` are preferred over the deprecated ones from `@fluidframework/tree`. */
packages/dds/tree/src/index.ts:21
- The type name 'Listeners' is too generic and can cause confusion. Consider renaming it to something more specific like 'EventListeners'.
Listeners,
packages/dds/tree/src/index.ts:25
- The type name 'IsListener' is ambiguous. Consider renaming it to something more descriptive like 'IsEventListener'.
IsListener,
packages/dds/tree/src/index.ts:29
- The type name 'Listenable' is too generic and can cause confusion. Consider renaming it to something more specific like 'EventListenable'.
Listenable,
packages/dds/tree/src/index.ts:33
- The type name 'Off' is too generic and can cause confusion. Consider renaming it to something more specific like 'EventOff'.
Off,
Tip: Copilot code review supports C#, Go, Java, JavaScript, Markdown, Python, Ruby and TypeScript, with more languages coming soon. Learn more
bc86952
to
c6455be
Compare
export type { | ||
/** | ||
* @deprecated Deprecated in `@fluidframework/tree`. Consider importing from `fluid-framework` or `@fluidframework/core-interfaces` instead. | ||
*/ | ||
Listeners, | ||
/** | ||
* @deprecated Deprecated in `@fluidframework/tree`. Consider importing from `fluid-framework` or `@fluidframework/core-interfaces` instead. | ||
*/ | ||
IsListener, | ||
/** | ||
* @deprecated Deprecated in `@fluidframework/tree`. Consider importing from `fluid-framework` or `@fluidframework/core-interfaces` instead. | ||
*/ | ||
Listenable, | ||
/** | ||
* @deprecated Deprecated in `@fluidframework/tree`. Consider importing from `fluid-framework` or `@fluidframework/core-interfaces` instead. | ||
*/ | ||
Off, | ||
} from "@fluidframework/core-interfaces"; |
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.
Looks like this is actually insufficient. While tsc supports this pattern, api-extactor and eslint do not. Notice that there is no API report change here.
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 same applies to the previous approach—there are no API Extractor updates for those changes either. But it shows the usual strikethrough in VSCode to indicate these types are deprecated.
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.
One approach is to copy these types in tree, mark them as deprecated, and export them from there. This will update the api-extractor reports to reflect the deprecation status of these types.
59a4ebe
to
0594542
Compare
🔗 No broken links found! ✅ Your attention to detail is admirable. linkcheck output
|
0594542
to
c6455be
Compare
Add a changeset to deprecate types from @fluidframework/tree. Modify fluid-framework to re-export the non-deprecated APIs from core-interfaces.
Added basic test cases which covers importing a type from the three packages: tree, core-interfaces, and fluid-framework. These tests are added under examples.
Prior PR: #23183
ADO#25440