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

generated .d.ts is stripped of comments when removeComments: true #261

Closed
TanxiangCode opened this issue Jan 28, 2021 · 3 comments
Closed
Labels
kind: support Asking for support with something or a specific use case problem: needs more info This issue needs more information in order to handle it problem: stale Issue has not been responded to in some time solution: tsc behavior This is tsc's behavior as well, so this is not a bug with this plugin

Comments

@TanxiangCode
Copy link

TanxiangCode commented Jan 28, 2021

What happens and why it is wrong

  1. There is no comment content in the d.ts declaration file generated by the vue file
  2. Private members are also defined in the declaration file

Environment

Versions

    "rollup": "^2.38.0",
    "rollup-plugin-babel": "^4.4.0",
    "rollup-plugin-cleaner": "^1.0.0",
    "rollup-plugin-cleanup": "^3.2.1",
    "rollup-plugin-postcss": "^4.0.0",
    "rollup-plugin-terser": "^5.3.1",
    "rollup-plugin-typescript2": "^0.29.0",
    "rollup-plugin-vue": "^5.1.9",

rollup.config.js

`rollup.config.js`:
typescript({
      tsconfig: './tsconfig.json',
      abortOnError: false,
      tsconfigOverride: {
        declaration: true,
        declarationDir: './lib',
        emitDeclarationOnly: true,
        noImplicitAny: false,
        removeComments: true,
        exclude: ['node_modules', 'lib', 'dev'],
      })

tsconfig.json

`tsconfig.json`:
{
    "compilerOptions": {
        "target": "esnext",
        "module": "esnext",
        "strict": true,
        "jsx": "preserve",
        "importHelpers": true,
        "moduleResolution": "node",
        "experimentalDecorators": true,
        "skipLibCheck": true,
        "esModuleInterop": true,
        "allowSyntheticDefaultImports": true,
        "sourceMap": true,
        "baseUrl": ".",
        "composite": false,
        "declaration": true,
        "declarationDir": "./lib",
        "emitDeclarationOnly": false,
        "noImplicitAny": false,
        "removeComments": true,
        "types": [
            "node",
            "vue"
        ],
        "paths": {
            "@qinglan-ui/*": [
                "packages/*"
            ]
        },
        "lib": [
            "esnext",
            "dom",
            "dom.iterable",
            "scripthost"
        ]
    },
    "exclude": [
        "node_modules",
        "lib",
    ]
}

package.json

`package.json`:

plugin output with verbosity 3

plugin output with verbosity 3:
import { Vue } from 'vue-property-decorator';
import { ITableColumn } from './table';
export default class Table extends Vue {
    data: any;
    columnData: Array<ITableColumn>;
    private getIndex;
}
@ezolenko
Copy link
Owner

ezolenko commented Feb 5, 2021

Is this different from what typescript would generate if you call it directly outside of rollup?

@agilgur5 agilgur5 changed the title d.ts no comment content generated .d.ts is stripped of comments Apr 23, 2022
@agilgur5 agilgur5 added problem: needs more info This issue needs more information in order to handle it problem: stale Issue has not been responded to in some time solution: tsc behavior This is tsc's behavior as well, so this is not a bug with this plugin kind: support Asking for support with something or a specific use case labels Apr 23, 2022
@agilgur5 agilgur5 changed the title generated .d.ts is stripped of comments generated .d.ts is stripped of comments when removeComments: true Apr 23, 2022
@agilgur5
Copy link
Collaborator

agilgur5 commented Apr 23, 2022

OP has removeComments: true in their tsconfig.json (and tsconfigOverride as well), which, per the docs (and its name), strips comments.

So I believe tsc would have similar output, as that's what it was configured to do.

Closing as that seems to be correct behavior (unless .d.ts is supposed to have comments while .js isn't? the docs aren't clear on that), and because OP never responded to requests for more information.

@ImLunaHey
Copy link

Related: microsoft/TypeScript#14619

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: support Asking for support with something or a specific use case problem: needs more info This issue needs more information in order to handle it problem: stale Issue has not been responded to in some time solution: tsc behavior This is tsc's behavior as well, so this is not a bug with this plugin
Projects
None yet
Development

No branches or pull requests

4 participants