-
-
Notifications
You must be signed in to change notification settings - Fork 25
feat: add TypeScript related extensions support #85
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| { | ||
| "plugins": ["./test.mts"] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import assert from 'node:assert/strict' | ||
|
|
||
| export default function test() { | ||
| assert(typeof globalThis.unifiedEngineTestCalls === 'number') | ||
| globalThis.unifiedEngineTestCalls++ | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| { | ||
| "plugins": ["./test.ts"] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| { | ||
| "type": "module" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import assert from 'node:assert/strict' | ||
|
|
||
| export default function test() { | ||
| assert(typeof globalThis.unifiedEngineTestCalls === 'number') | ||
| globalThis.unifiedEngineTestCalls++ | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| /** | ||
| * @import {Preset} from 'unified-engine' | ||
| */ | ||
|
|
||
| /** @type {Preset} */ | ||
| const config = {settings: {}} | ||
|
|
||
| export default config |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import type {Preset} from 'unified-engine' | ||
|
|
||
| const config: Preset = { | ||
| settings: { | ||
| foo: 'bar' | ||
| } | ||
| } | ||
|
|
||
| export default config |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,5 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| import type {Settings} from 'unified' | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| exports.settings = { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| foo: 'bar' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } satisfies Settings | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+1
to
+5
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TypeScript doesn’t understand the
Suggested change
or use an ESM style export (doesn’t work with
Suggested change
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not all features are supported by Node type stripping.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know, though I don’t know entirely for sure which features are or aren’t supported. If neither of these syntaxes is supported by Node.js type stripping, then it doesn’t support
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I consider a module format supported, if there’s a way to import and export things in a way that TypeScript understands. In CJS, for imports means at least one of: import module = require('module')
import {member} from 'module'And for exports that means at least one of: export = {}
export const member = {}If there’s no (proper) way to import or export from a
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The test case is still a valid We're talking about Node type stripping, and it's how Using So IMO,
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It’s not valid We shouldn’t promote this anti-pattern, especially considering this is already a topic of confusion in the TypeScript community. |
||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import type {Preset} from 'unified-engine' | ||
|
|
||
| declare module 'unified' { | ||
| interface Settings { | ||
| foo: string | ||
| } | ||
| } | ||
|
|
||
| const config: Preset = { | ||
| settings: { | ||
| foo: 'bar' | ||
| } | ||
| } | ||
|
|
||
| export default config |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this not come before
.js? Or is it intentional that built JS is preferred over TSNext to docs, tests are missing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally I think js configs should be preferred because they're supported natively and this is just old behavior, what means if a user have a
.remarkrc.tscompiled into.remarkrx.jsmanually, this will continue work even on unsupported Node versions.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point, probably!