Modules plugin doesn't load or compile .ts files without a language header · Issue #52 · polyipseity/obsidian-modules · GitHub
Skip to content

Modules plugin doesn't load or compile .ts files without a language header #52

Open

Description

@benzaria

Description

I'm experiencing an issue with the Modules plugin in Obsidian where .ts files are not detected as TypeScript when used as startup modules.

A TypeScript file only seems to work when I explicitly add the language header:

// { "language": "TypeScript" }

Without this header, the plugin appears unable to recognize the file as TypeScript, even though the file already has the .ts extension.

Unexpected behavior

The plugin also run the default function twice every time it loads or reloads for some reason!

stack
index.ts:4 "default"
    at dtest (index.ts:8:7)
    at vHt (plugin:modules:47142:17880)
    at async yHt (plugin:modules:47142:17520)
    at async eval (plugin:modules:47142:15961)
    at async Promise.all (index 0)
    at async Xxe.load (plugin:modules:47142:16295)
    at async Hlt (plugin:modules:47142:17424)
    at async zlt (plugin:modules:47143:634)
    at async Promise.all (index 1)
    at async eval (plugin:modules:47143:17096)

index.ts:4 "default"
    at dtest (index.ts:8:7)
    at vHt (plugin:modules:47142:17880)
    at async yHt (plugin:modules:47142:17520)
    at async eval (plugin:modules:47142:15961)
    at async Promise.all (index 0)
    at async Xxe.load (plugin:modules:47142:16295)

Steps to reproduce

test.ts

export function test(str: string = 'test') {
	console.log(str)
}

export default function dtest() {
	test(new Error('default'))
}
stack
plugin:modules:47131
Error loading module: modules/test.ts
 SyntaxError: Unexpected token ':' (at 45a2ac7d-d8f1-49a0-abcd-4b861266af42:2:25)
 
IF                @ plugin:modules:47131
yHt               @ plugin:modules:47142
await in yHt
eval              @ plugin:modules:47142
D                 @ plugin:modules:47142
eval              @ plugin:modules:47142
eval              @ plugin:modules:47130
eval              @ plugin:modules:47130
load              @ plugin:modules:47142
Hlt               @ plugin:modules:47142
zlt               @ plugin:modules:47143
await in zlt
eval              @ plugin:modules:47143
await in eval
onload            @ plugin:modules:47143

Environment

  • Obsidian: 1.14.4
  • Modules: 2.5.2

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions