Skip to content
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

isolatedDeclarations doesn't support tsconfig options #3958

Closed
tombl opened this issue Jun 28, 2024 · 5 comments · Fixed by #5878
Closed

isolatedDeclarations doesn't support tsconfig options #3958

tombl opened this issue Jun 28, 2024 · 5 comments · Fixed by #5878
Assignees
Labels
A-isolated-declarations Isolated Declarations C-enhancement Category - New feature or request

Comments

@tombl
Copy link

tombl commented Jun 28, 2024

Some tsconfig options are relevant for declaration emit, but there's currently no way to pass these.

> code = "/** @internal */ export function hello() {}"

> require("oxc-transform").isolatedDeclaration("example.ts", code)
{ errors: ['TS9007: Function must have an explicit return type annotation with --isolatedDeclarations.'] }

> require("typescript").transpileDeclaration(code, {})
{
  diagnostics: [{
    messageText: 'Function must have an explicit return type annotation with --isolatedDeclarations.',
  }]
}

> require("typescript").transpileDeclaration(code, { compilerOptions: { stripInternal: true } })
{ outputText: 'export {};\n' }
@tombl tombl added the C-enhancement Category - New feature or request label Jun 28, 2024
@Dunqing Dunqing added the A-isolated-declarations Isolated Declarations label Jun 29, 2024
@Dunqing Dunqing self-assigned this Jun 29, 2024
@Dunqing
Copy link
Member

Dunqing commented Jun 29, 2024

Thanks for trying it out, in addition to supporting passing tsconfig options we also need to check the jsdoc @Boshen cc

@Boshen
Copy link
Member

Boshen commented Jul 2, 2024

https://x.com/TitianCernicova/status/1808132493469442398

If stripInternal is specified TSC will respect the internal JSDoc tag even if ID is specified, and this is the behavior that is expected of other DTS implementations.

internal is useful as an escape hatch for functions you might export from a module, but don't actually want to export from your package so they don't need to make it into declaration files.

@Boshen
Copy link
Member

Boshen commented Aug 18, 2024

Close as not planned. It seems like ID shouldn't check jsdoc nor tsconfig :-/

@Boshen Boshen closed this as not planned Won't fix, can't repro, duplicate, stale Aug 18, 2024
@tombl
Copy link
Author

tombl commented Aug 18, 2024

It's my understanding that isolatedDeclarations is mostly about not running a full typechecker to emit declarations.
Are there potential perf issues with supporting this or is it simply out of scope?

@Dunqing Dunqing reopened this Sep 10, 2024
@Dunqing
Copy link
Member

Dunqing commented Sep 10, 2024

I've found that most of the popular libraries use @internal directive and strip them by stripInternal. So I think we should consider supporting it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-isolated-declarations Isolated Declarations C-enhancement Category - New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants