Skip to content

Commit 3dfa53a

Browse files
pajomaclaude
andcommitted
fix: move extractScopeAndTags to base Input — runtime cast was invalid
The (input as NoteInput) cast is TypeScript-only; at runtime Parser receives plain Input objects from parseInput(), causing "extractScopeAndTags is not a function". The service contract resolveNotePathForInput(input: Input) requires the method on Input. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 66d0580 commit 3dfa53a

2 files changed

Lines changed: 13 additions & 17 deletions

File tree

src/journal/parser.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
'use strict';
1919

2020
import * as Path from 'path';
21-
import { IConfiguration, ILogger, Input, NoteInput } from '../model';
21+
import { IConfiguration, ILogger, Input } from '../model';
2222
import { normalizeFilename, getCurrentISOWeek, getISOWeekYear } from '../util';
2323
import { MatchInput } from './match-input';
2424

@@ -46,7 +46,7 @@ export class Parser {
4646
this.logger.trace("Entering resolveNotePathForInput() in actions/parser.ts");
4747

4848
const date = new Date();
49-
(input as NoteInput).extractScopeAndTags(this.config.getScopes());
49+
input.extractScopeAndTags(this.config.getScopes());
5050
this.logger.trace("Tags in input: " + input.tags + ", scope: " + input.scope);
5151

5252
const inputForFileName = normalizeFilename(input.text);

src/model/input.ts

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,19 @@ export class Input {
172172
}
173173
let date = new Date();
174174
date.setDate(date.getDate() + this.offset);
175-
return date;
176-
175+
return date;
177176
}
178177

179-
180-
178+
public extractScopeAndTags(availableScopes: string[]): void {
179+
this._text.match(/#\w+(?:\s|$)/g)?.forEach(match => {
180+
const tag = match.trim();
181+
this._tags.push(tag);
182+
this._text = this._text.replace(match, " ");
183+
const scopeName = tag.substring(1);
184+
const matched = availableScopes.find(name => name === scopeName);
185+
if (matched) { this._scope = matched; }
186+
});
187+
}
181188
}
182189

183190
export class NoteInput extends Input {
@@ -190,17 +197,6 @@ export class NoteInput extends Input {
190197

191198
public get path() { return this._path; }
192199
public set path(path: string) { this._path = path; }
193-
194-
public extractScopeAndTags(availableScopes: string[]): void {
195-
this._text.match(/#\w+(?:\s|$)/g)?.forEach(match => {
196-
const tag = match.trim();
197-
this._tags.push(tag);
198-
this._text = this._text.replace(match, " ");
199-
const scopeName = tag.substring(1);
200-
const matched = availableScopes.find(name => name === scopeName);
201-
if (matched) { this._scope = matched; }
202-
});
203-
}
204200
}
205201

206202
export class SelectedInput extends Input {

0 commit comments

Comments
 (0)