Skip to content

Can I use the NPM parser to parse TypeScript? #3108

Closed Answered by Sleepful
Sleepful asked this question in Q&A
Discussion options

You must be logged in to vote

@Boshen oh, you are right. I see what you mean now.

This works fine:

parseSync(`import type { Signal } from "@preact/signals";`, {
  sourceFilename: "some.ts",
})

Now that I remember, I had looked at https://github.com/oxc-project/oxc/blob/main/napi/parser/index.d.ts#L82 before posting this discussion, but I was looking for something like "filetype" that I could tell it "TypeScript". It didn't occur to me that sourceFilename was important! Adding a sample in the README for the NPM package where sourceFilename is used for a TS file would have been enough.

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@Sleepful
Comment options

@Sleepful
Comment options

@Boshen
Comment options

@Sleepful
Comment options

Answer selected by Sleepful
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants