-
Notifications
You must be signed in to change notification settings - Fork 0
Remove flat exports, enforce namespace-only imports (BREAKING CHANGE) #63
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
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
|
@copilot 既然您不需要考虑向后兼容性,目前的 PR 实现(保留了 您应该直接删除 以下是具体的处理建议: 1. 修改
|
Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
Done! I've removed all flat exports from Changes made (commit fb3126a):
This completely eliminates the risk of naming conflicts by enforcing clear namespace boundaries. All types must now be accessed through protocol namespaces. |
| // STYLE 1: Namespace Imports from Root | ||
| // ============================================================================ | ||
|
|
||
| import { Data, UI, System, AI } from '@objectstack/spec'; |
Check notice
Code scanning / CodeQL
Unused variable, import, function or class Note test
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 1 day ago
In general, the correct fix for unused imports is to remove any bindings that are not referenced in the file, while keeping still-used imports intact. This improves clarity and avoids unnecessary module loading.
For this specific file, the best minimal fix is to adjust the root namespace import on line 12 so that it only imports Data, since UI, System, and AI are never used anywhere in the snippet (other styles demonstrate those via other imports). No other code changes are needed because no code refers to UI, System, or AI from the root import. The change is confined to packages/spec/examples/namespaced-imports.example.ts, modifying the single import statement at the top of the file to:
import { Data } from '@objectstack/spec';No new methods, definitions, or additional imports are required.
-
Copy modified line R12
| @@ -9,7 +9,7 @@ | ||
| // STYLE 1: Namespace Imports from Root | ||
| // ============================================================================ | ||
|
|
||
| import { Data, UI, System, AI } from '@objectstack/spec'; | ||
| import { Data } from '@objectstack/spec'; | ||
|
|
||
| // Use with namespace prefix | ||
| const field1: Data.Field = { |
| // ============================================================================ | ||
|
|
||
| import * as DataNS from '@objectstack/spec/data'; | ||
| import * as UINS from '@objectstack/spec/ui'; |
Check notice
Code scanning / CodeQL
Unused variable, import, function or class Note test
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 1 day ago
In general, unused imports should be removed to keep the code clear and avoid misleading readers about dependencies. Here, the UINS namespace imported from '@objectstack/spec/ui' is never used; all UI-related typing in the snippet is handled either via the root UI namespace (from @objectstack/spec) or via the direct View import later on. Removing this line will not change runtime or type-checking behavior, as the symbol UINS has no references.
The best fix is to delete the single unused import line in packages/spec/examples/namespaced-imports.example.ts at line 27: import * as UINS from '@objectstack/spec/ui';. No other changes are necessary, and no additional imports or definitions are required elsewhere in the file. This preserves all existing functionality and still demonstrates the intended import styles via the remaining imports.
| @@ -24,7 +24,6 @@ | ||
| // ============================================================================ | ||
|
|
||
| import * as DataNS from '@objectstack/spec/data'; | ||
| import * as UINS from '@objectstack/spec/ui'; | ||
| import * as SystemNS from '@objectstack/spec/system'; | ||
| import * as AINS from '@objectstack/spec/ai'; | ||
|
|
|
|
||
| import * as DataNS from '@objectstack/spec/data'; | ||
| import * as UINS from '@objectstack/spec/ui'; | ||
| import * as SystemNS from '@objectstack/spec/system'; |
Check notice
Code scanning / CodeQL
Unused variable, import, function or class Note test
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 1 day ago
In general, unused imports should be removed to keep code clean, avoid confusion, and prevent unnecessary dependencies from being pulled into the module scope. Since SystemNS is never used in the shown code, the best fix is simply to delete the unused import statement rather than inventing dummy usages that add no value.
Concretely, in packages/spec/examples/namespaced-imports.example.ts, locate the "STYLE 2: Namespace Imports via Subpath" section. Remove the line import * as SystemNS from '@objectstack/spec/system'; (line 28 in your snippet), leaving the other namespace imports (DataNS, UINS, AINS) unchanged. No additional methods, variables, or imports are needed; we are only deleting the unused import and not altering functionality, since it was not used.
| @@ -25,7 +25,6 @@ | ||
|
|
||
| import * as DataNS from '@objectstack/spec/data'; | ||
| import * as UINS from '@objectstack/spec/ui'; | ||
| import * as SystemNS from '@objectstack/spec/system'; | ||
| import * as AINS from '@objectstack/spec/ai'; | ||
|
|
||
| // Use with namespace prefix for clarity |
| import * as DataNS from '@objectstack/spec/data'; | ||
| import * as UINS from '@objectstack/spec/ui'; | ||
| import * as SystemNS from '@objectstack/spec/system'; | ||
| import * as AINS from '@objectstack/spec/ai'; |
Check notice
Code scanning / CodeQL
Unused variable, import, function or class Note test
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 1 day ago
In general, unused imports should be removed to avoid confusion and to slightly improve performance and tooling feedback. Here, the best fix is to delete the unused namespace import import * as AINS from '@objectstack/spec/ai'; while keeping the rest of the example intact.
Concretely, in packages/spec/examples/namespaced-imports.example.ts, remove the line that imports AINS. No other code changes are needed because nothing in the shown code references AINS, and the file already demonstrates AI-related imports in STYLE 3 via Agent and ModelProvider. This preserves existing functionality and keeps the example clear.
| @@ -26,7 +26,6 @@ | ||
| import * as DataNS from '@objectstack/spec/data'; | ||
| import * as UINS from '@objectstack/spec/ui'; | ||
| import * as SystemNS from '@objectstack/spec/system'; | ||
| import * as AINS from '@objectstack/spec/ai'; | ||
|
|
||
| // Use with namespace prefix for clarity | ||
| const field2: DataNS.Field = { |
|
@copilot fix ci build test typecheck |
Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
Fixed! Updated all imports in packages and examples to use the new namespace structure (commit 2cfa7e7). Changes:
CI build, test, and typecheck should now pass. |
|
@copilot fix |
|
@copilot and fix build |
| @@ -1,4 +1,4 @@ | |||
| import { QueryAST, FilterNode, SortNode, AggregationNode, WindowFunctionNode } from '@objectstack/spec'; | |||
| import { QueryAST, FilterNode, SortNode, AggregationNode, WindowFunctionNode } from '@objectstack/spec/data'; | |||
Check notice
Code scanning / CodeQL
Unused variable, import, function or class Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 1 day ago
In general, to fix an unused import, either remove it if it's not needed, or start using it in the code if it was meant to be used. Since there is no sign that WindowFunctionNode is required for existing functionality and no references to it appear in the snippet, the safest, non-functional change is to delete just that symbol from the import list.
Concretely, in packages/client/src/index.ts, edit the import on line 1 to remove WindowFunctionNode from the destructuring while leaving the other imported types intact. No additional imports, methods, or definitions are needed, and this change will not affect runtime behavior because type-only imports are erased at compile time, and this one was unused anyway.
-
Copy modified line R1
| @@ -1,4 +1,4 @@ | ||
| import { QueryAST, FilterNode, SortNode, AggregationNode, WindowFunctionNode } from '@objectstack/spec/data'; | ||
| import { QueryAST, FilterNode, SortNode, AggregationNode } from '@objectstack/spec/data'; | ||
|
|
||
| export interface ClientConfig { | ||
| baseUrl: string; |
| QueryAST, | ||
| QueryInput | ||
| } from '@objectstack/spec'; | ||
| import { QueryAST, QueryInput } from '@objectstack/spec/data'; |
Check notice
Code scanning / CodeQL
Unused variable, import, function or class Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 1 day ago
In general, to fix an unused import, you either (a) start using it meaningfully in the module, or (b) remove it from the import list. Since there is no evidence that QueryAST should be used (no related logic exists in the shown code), the safest and least intrusive fix is to remove only QueryAST from the import declaration while keeping QueryInput as-is.
Concretely, in packages/driver-memory/src/memory-driver.ts at line 1, change the import from destructuring both symbols to importing only QueryInput. No other lines or imports need to be touched, and no additional methods or definitions are required. This preserves existing functionality while resolving the unused-import warning.
-
Copy modified line R1
| @@ -1,4 +1,4 @@ | ||
| import { QueryAST, QueryInput } from '@objectstack/spec/data'; | ||
| import { QueryInput } from '@objectstack/spec/data'; | ||
| import { DriverInterface, DriverOptions } from '@objectstack/spec/system'; | ||
|
|
||
| /** |
Could you please clarify what needs to be fixed? Current status:
Are there specific CI failures, build errors, or test failures you're seeing that I should address? |
Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
Fixed! The build was failing because Changes:
Build should now pass successfully. |
Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
Plan: Fix CI Build, Test, and TypeCheck Issues ✅ COMPLETE
Problem
After removing flat exports, the build-schemas.ts script failed because it expected flat exports but now receives namespace exports (Data, UI, System, AI, API).
Changes Made
Build Script Fixes:
packages/spec/scripts/build-schemas.tsto iterate through namespace exportsHow it works:
Previous Updates
Packages Updated:
packages/client/src/index.ts- Data protocol importspackages/objectql/src/registry.ts- Data, UI, System importspackages/objectql/src/index.ts- Data and System importspackages/runtime/src/kernel.ts- Data protocol importspackages/driver-memory/src/memory-driver.ts- Data and System importspackages/driver-memory/objectstack.config.ts- System importsExamples Updated:
Benefits
Files Changed: 35 files (34 source files + 1 build script)
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.