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

inline comments are striped in emitted declaration files #28199

Open
Hotell opened this issue Oct 29, 2018 · 3 comments
Open

inline comments are striped in emitted declaration files #28199

Hotell opened this issue Oct 29, 2018 · 3 comments
Labels
Needs Proposal This issue needs a plan that clarifies the finer details of how it could be implemented. Suggestion An idea for TypeScript

Comments

@Hotell
Copy link

Hotell commented Oct 29, 2018

TypeScript Version: 3.1.3

Search Terms: inline comments striped

tsconfig

{
  "compilerOptions": {
    "moduleResolution": "node",
    "module": "esnext",
    "target": "es5",
    "lib": [
      "dom",
      "es2018"
    ],
    "strict": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "suppressImplicitAnyIndexErrors": true,
    "forceConsistentCasingInFileNames": true,
    "jsx": "react",
    "sourceMap": true,
    "outDir": "dist/esm5",
    "declaration": true,
    "declarationDir": "dist/types",
    "declarationMap": true,
    "stripInternal": true,
    "resolveJsonModule": true,
    "importHelpers": true
  },
  "include": [
    "./src"
  ],
  "compileOnSave": false,
  "buildOnSave": false
}

Code:

// I'll be missing after tsc 😭

/**
 * I'll be here after tsc 😎
 */

export const api = () => { /* some code ... */ } 

Expected behavior:

Keeping both block and inline comments in declaration files in both transpiled files and declaration files

Actual behavior:

Inline comments are removed in declaration files
image

And correctly kept within transpiled files
image

@weswigham weswigham added Suggestion An idea for TypeScript Needs Proposal This issue needs a plan that clarifies the finer details of how it could be implemented. labels Oct 29, 2018
@weswigham
Copy link
Member

Multiline comments are preserved by declaration emit because they're typically documentation comments for quick info and the like. (We don't interpret single line comments as docs, afaik)

@Hotell
Copy link
Author

Hotell commented Nov 1, 2018

While that makes sense, it's not consistent :) so what's gonna happen / is there anything I can do on my side ?

@jrom99
Copy link

jrom99 commented Feb 13, 2024

Hello, this is causing a bug when I wrote a UserScript that needs inline comments for its metadata:

image image

It seems that typescript is removing all root inline comments.

System information:

tsc version 5.3.3

// tsconfig.json
{
  "compilerOptions": {
    "target": "ES2022",
    "module": "ES2022",
    "lib": ["es2022", "dom"],
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "strict": true,
    "removeComments": false,
    "skipLibCheck": true
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Proposal This issue needs a plan that clarifies the finer details of how it could be implemented. Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

3 participants