fix: module @codemirror/state does not provide an export named Extension #3

Closed
milahu wants to merge 1 commit from patch-1 into main
milahu commented 2022-09-11 11:45:20 +02:00 (Migrated from github.com)

found this error when copy-pasting from https://github.com/codemirror/basic-setup

import {Extension, EditorState} from "@codemirror/state"
Uncaught SyntaxError: The requested module @codemirror/state does not provide an export named 'Extension' (at App.jsx:48:9)

fixed by removing the Extension import in my code

relevant code

github.com/codemirror/state@8725a90b18/src/index.ts (L3)

export {Facet, StateField, Extension, Prec, Compartment} from "./facet"

github.com/codemirror/state@8725a90b18/src/facet.ts (L343)

export type Extension = {extension: Extension} | readonly Extension[]

as far as i can tell, Extension is only a type

found this error when copy-pasting from https://github.com/codemirror/basic-setup ```js import {Extension, EditorState} from "@codemirror/state" ``` ``` Uncaught SyntaxError: The requested module @codemirror/state does not provide an export named 'Extension' (at App.jsx:48:9) ``` fixed by removing the `Extension` import in my code relevant code https://github.com/codemirror/state/blob/8725a90b185bdfac81e3d2c1fef1a8fd9435e774/src/index.ts#L3 ```ts export {Facet, StateField, Extension, Prec, Compartment} from "./facet" ``` https://github.com/codemirror/state/blob/8725a90b185bdfac81e3d2c1fef1a8fd9435e774/src/facet.ts#L343 ```ts export type Extension = {extension: Extension} | readonly Extension[] ``` as far as i can tell, `Extension` is only a type
marijnh commented 2022-09-11 12:32:21 +02:00 (Migrated from github.com)

as far as i can tell, Extension is only a type

That's correct. But TypeScript code can import types. So what is the problem here?

> as far as i can tell, Extension is only a type That's correct. But TypeScript code can import types. So what is the problem here?
milahu commented 2022-09-11 13:31:05 +02:00 (Migrated from github.com)

So what is the problem here?

copy-pasting from typescript to javascript

the import type syntax would show that this is "typescript only"
but its more verbose ...

> So what is the problem here? copy-pasting from typescript to javascript the `import type` syntax would show that this is "typescript only" but its more verbose ...
marijnh commented 2022-09-11 14:01:47 +02:00 (Migrated from github.com)

copy-pasting from typescript to javascript

That's not generally something that works, and is not a use case this code tries to address.

> copy-pasting from typescript to javascript That's not generally something that works, and is not a use case this code tries to address.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
codemirror/basic-setup!3
No description provided.