-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
Ran 'git clone https://github.com/obsidianmd/obsidian-sample-plugin.git'
Ran 'npm install --save-dev' and received a deprecation error for server packages.
npm warn deprecated [email protected]: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
npm warn deprecated @humanwhocodes/[email protected]: Use @eslint/config-array instead
npm warn deprecated [email protected]: Rimraf versions prior to v4 are no longer supported
npm warn deprecated [email protected]: Glob versions prior to v9 are no longer supported
npm warn deprecated @humanwhocodes/[email protected]: Use @eslint/object-schema instead
I ran 'npm run dev' and every worked fine. If I upgrade the deprecated modules I receive the following:
I'm building another obsidian.md plugin usnig typescript. Attached is my 'main.ts' file. When I type 'npm run build' I receive the following errors:
src/main.ts:14:2 - error TS2564: Property 'settings' has no initializer and is not definitely assigned in the constructor.
14 settings: MyPluginSettings;
~~~~~~~~
src/main.ts:43:4 - error TS2322: Type '(editor: Editor, view: MarkdownView) => void' is not assignable to type '(editor: Editor, ctx: MarkdownView | MarkdownFileInfo) => any'.
Types of parameters 'view' and 'ctx' are incompatible.
Type 'MarkdownView | MarkdownFileInfo' is not assignable to type 'MarkdownView'.
Type 'MarkdownFileInfo' is missing the following properties from type 'MarkdownView': previewMode, currentMode, getViewType, getMode, and 39 more.
43 editorCallback: (editor: Editor, view: MarkdownView) => {
~~~~~~~~~~~~~~
node_modules/obsidian/obsidian.d.ts:726:5
726 editorCallback?: (editor: Editor, ctx: MarkdownView | MarkdownFileInfo) => any;
~~~~~~~~~~~~~~
The expected type comes from property 'editorCallback' which is declared here on type 'Command'
Found 2 errors in the same file, starting at: src/main.ts:14
This fix resolves the issue.
Explanation:
- Property 'settings' has no initializer and is not definitely assigned in the constructor:
This error occurs because TypeScript expects the settings property to be initialized in the constructor or declared with a definite assignment assertion. To fix this, you can initialize settings with a default value or mark it with a definite assignment assertion (!).
- Type '(editor: Editor, view: MarkdownView) => void' is not assignable to type '(editor: Editor, ctx: MarkdownView | MarkdownFileInfo) => any':
This error occurs because the type signature for editorCallback in your Command expects the second parameter to be either a MarkdownView or MarkdownFileInfo. However, your callback currently only handles MarkdownView. You'll need to update the type signature to accommodate both types or ensure the correct type handling.