-
Couldn't load subscription status.
- Fork 70
Closed
Labels
kind: supportAsking for support with something or a specific use caseAsking for support with something or a specific use caseproblem: no reproNo reproduction was provided (and have not tried to repro without one)No reproduction was provided (and have not tried to repro without one)problem: staleIssue has not been responded to in some timeIssue has not been responded to in some timescope: ViteRelated to integration with Vite, not Rollup, which this plugin was designed forRelated to integration with Vite, not Rollup, which this plugin was designed forscope: integrationRelated to an integration, not necessarily to core (but could influence core)Related to an integration, not necessarily to core (but could influence core)solution: invalidThis doesn't seem rightThis doesn't seem rightsolution: unresolvedIssue has been closed by OP but root cause has not necessarily been resolvedIssue has been closed by OP but root cause has not necessarily been resolvedsolution: workaround availableThere is a workaround available for this issueThere is a workaround available for this issuetopic: monorepo / symlinksRelated to monorepos and/or symlinks (Lerna, Yarn, PNPM, Rush, etc)Related to monorepos and/or symlinks (Lerna, Yarn, PNPM, Rush, etc)
Description
What happens and why it is wrong
I am going to develop react components with vite and in monorepo mode.
When I build a react component the .d.ts file generate successfully, but the type of the component props goes any instead of what I set in component source code.
And I run tsc src/index.tsx --declaration --emitDeclarationOnly --jsx react --esModuleInterop --outDir types it works correct. here .d.ts output:
rollup-plugin-typescript2:
import React from "react";
declare function BaseSelect(props: any): React.FunctionComponentElement<any>;
export default BaseSelect;tsc:
import React from 'react';
import { SelectProps } from 'antd/lib/select';
export declare type OptionValueType = string | number;
export interface SelectOptionType {
key?: string;
value?: OptionValueType;
label?: string;
disabled?: boolean;
children?: React.ReactChild;
[key: string]: any;
}
export interface BaseSelectProps<VT> extends Omit<SelectProps<VT>, 'options'> {
optionLabelAlias?: string;
optionValueAlias?: string;
options: SelectOptionType[];
}
declare function BaseSelect<VT extends OptionValueType = OptionValueType>(props: BaseSelectProps<VT>): JSX.Element;
export default BaseSelect;Versions
rollup-plugin-typescript2: ^0.30.0 => 0.30.0
typescript: 3.8.3 => 3.8.3
vite.config.js
`vite.config.js`:
import { defineConfig } from 'vite'
import typescript from 'rollup-plugin-typescript2'
import path from 'path'
import reactRefresh from '@vitejs/plugin-react-refresh'
const cwd = process.cwd()
const entry = `${cwd}/src/index.tsx`
const name = path.basename(cwd)
export default defineConfig({
build: {
minify: false,
lib: {
entry,
name,
},
rollupOptions: {
external: ['react', /antd/, /@ant-design/, 'axios'],
output: [
{
format: 'cjs',
assetFileNames: 'css/main.[ext]',
exports: 'named',
},
{
format: 'es',
assetFileNames: 'css/main.[ext]',
exports: 'named',
},
],
plugins: [
typescript({
useTsconfigDeclarationDir: true,
tsconfigOverride: {
compilerOptions: {
declarationDir: path.resolve(cwd, './types'),
},
include: [path.resolve(cwd, './src')],
},
}),
],
},
},
plugins: [reactRefresh()],
css: {
preprocessorOptions: {
less: {
javascriptEnabled: true,
},
},
},
})tsconfig.json
`tsconfig.json`:
{
"compilerOptions": {
"target": "ESNext",
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"allowJs": false,
"skipLibCheck": false,
"esModuleInterop": true,
"declaration": true,
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"moduleResolution": "Node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react",
}
}plugin output with verbosity 3
plugin output with verbosity 3:
rpt2: built-in options overrides: {
"noEmitHelpers": false,
"importHelpers": true,
"noResolve": false,
"noEmit": false,
"inlineSourceMap": false,
"outDir": "/Users/liqing/Desktop/boss-react-components/packages/boss-base-select/node_modules/.cache/rollup-plugin-typescript2/placeholder",
"moduleResolution": 2,
"allowNonTsExtensions": true
}
rpt2: parsed tsconfig: {
"options": {
"target": 99,
"lib": [
"lib.dom.d.ts",
"lib.dom.iterable.d.ts",
"lib.esnext.d.ts"
],
"allowJs": false,
"skipLibCheck": false,
"esModuleInterop": true,
"declaration": true,
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"module": 99,
"moduleResolution": 2,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": false,
"jsx": 2,
"declarationDir": "/Users/liqing/Desktop/boss-react-components/packages/boss-base-select/types",
"configFilePath": "/Users/liqing/Desktop/boss-react-components/tsconfig.json",
"noEmitHelpers": false,
"importHelpers": true,
"noResolve": false,
"inlineSourceMap": false,
"outDir": "/Users/liqing/Desktop/boss-react-components/packages/boss-base-select/node_modules/.cache/rollup-plugin-typescript2/placeholder",
"allowNonTsExtensions": true
},
"fileNames": [
"/Users/liqing/Desktop/boss-react-components/packages/boss-base-select/src/index.tsx"
],
"typeAcquisition": {
"enable": false,
"include": [],
"exclude": []
},
"raw": {
"compilerOptions": {
"target": "ESNext",
"lib": [
"DOM",
"DOM.Iterable",
"ESNext"
],
"allowJs": false,
"skipLibCheck": false,
"esModuleInterop": true,
"declaration": true,
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"moduleResolution": "Node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react",
"declarationDir": "/Users/liqing/Desktop/boss-react-components/packages/boss-base-select/types"
},
"include": [
"/Users/liqing/Desktop/boss-react-components/packages/boss-base-select/src"
],
"compileOnSave": false
},
"errors": [],
"wildcardDirectories": {
"/Users/liqing/Desktop/boss-react-components/packages/boss-base-select/src": 1
},
"compileOnSave": false,
"configFileSpecs": {
"includeSpecs": [
"/Users/liqing/Desktop/boss-react-components/packages/boss-base-select/src"
],
"excludeSpecs": [
"/Users/liqing/Desktop/boss-react-components/packages/boss-base-select/types"
],
"validatedIncludeSpecs": [
"/Users/liqing/Desktop/boss-react-components/packages/boss-base-select/src"
],
"validatedExcludeSpecs": [
"/Users/liqing/Desktop/boss-react-components/packages/boss-base-select/types"
],
"wildcardDirectories": {
"/Users/liqing/Desktop/boss-react-components/packages/boss-base-select/src": 1
}
}
}
rpt2: typescript version: 3.8.3
rpt2: tslib version: 2.1.0
rpt2: rollup version: 2.51.1
rpt2: rollup-plugin-typescript2 version: 0.30.0
rpt2: plugin options:
{
"useTsconfigDeclarationDir": true,
"tsconfigOverride": {
"compilerOptions": {
"declarationDir": "/Users/liqing/Desktop/boss-react-components/packages/boss-base-select/types"
},
"include": [
"/Users/liqing/Desktop/boss-react-components/packages/boss-base-select/src"
]
},
"verbosity": 3,
"check": true,
"clean": false,
"cacheRoot": "/Users/liqing/Desktop/boss-react-components/packages/boss-base-select/node_modules/.cache/rollup-plugin-typescript2",
"include": [
"*.ts+(|x)",
"**/*.ts+(|x)"
],
"exclude": [
"*.d.ts",
"**/*.d.ts"
],
"abortOnError": true,
"rollupCommonJSResolveHack": false,
"transformers": [],
"tsconfigDefaults": {},
"objectHashIgnoreUnknownHack": false,
"cwd": "/Users/liqing/Desktop/boss-react-components/packages/boss-base-select",
"typescript": "version 3.8.3"
}
rpt2: rollup config:
{
"input": "/Users/liqing/Desktop/boss-react-components/packages/boss-base-select/src/index.tsx",
"preserveEntrySignatures": "strict",
"external": [
"react",
{},
{},
{},
"axios"
],
"output": [
{
"format": "cjs",
"assetFileNames": "css/main.[ext]",
"exports": "named"
},
{
"format": "es",
"assetFileNames": "css/main.[ext]",
"exports": "named"
}
],
"plugins": [
{
"name": "alias"
},
{
"name": "react-refresh",
"enforce": "pre"
},
{
"name": "vite:dynamic-import-polyfill"
},
{
"name": "vite:resolve"
},
{
"name": "vite:html"
},
{
"name": "vite:css"
},
{
"name": "vite:esbuild"
},
{
"name": "vite:json"
},
{
"name": "vite:wasm"
},
{
"name": "vite:worker"
},
{
"name": "vite:asset"
},
{
"name": "vite:define"
},
{
"name": "vite:css-post"
},
{
"name": "vite:build-html"
},
{
"name": "commonjs"
},
{
"name": "vite:data-uri"
},
{
"name": "rollup-plugin-dynamic-import-variables"
},
{
"name": "rpt2"
},
{
"name": "vite:import-analysis"
},
{
"name": "vite:esbuild-transpile"
},
{
"name": "vite:reporter"
}
]
}
rpt2: tsconfig path: /Users/liqing/Desktop/boss-react-components/tsconfig.json
rpt2: included:
[
"*.ts+(|x)",
"**/*.ts+(|x)"
]
rpt2: excluded:
[
"*.d.ts",
"**/*.d.ts"
]
rpt2: Ambient types:
rpt2: /Users/liqing/Desktop/boss-react-components/node_modules/@types/anymatch/index.d.ts
rpt2: /Users/liqing/Desktop/boss-react-components/node_modules/@types/babel__core/index.d.ts
rpt2: /Users/liqing/Desktop/boss-react-components/node_modules/@types/babel__generator/index.d.ts
rpt2: /Users/liqing/Desktop/boss-react-components/node_modules/@types/babel__template/index.d.ts
rpt2: /Users/liqing/Desktop/boss-react-components/node_modules/@types/babel__traverse/ts4.1/index.d.ts
rpt2: /Users/liqing/Desktop/boss-react-components/node_modules/@types/eslint-visitor-keys/index.d.ts
rpt2: /Users/liqing/Desktop/boss-react-components/node_modules/@types/estree/index.d.ts
rpt2: /Users/liqing/Desktop/boss-react-components/node_modules/@types/glob/index.d.ts
rpt2: /Users/liqing/Desktop/boss-react-components/node_modules/@types/graceful-fs/index.d.ts
rpt2: /Users/liqing/Desktop/boss-react-components/node_modules/@types/html-minifier-terser/index.d.ts
rpt2: /Users/liqing/Desktop/boss-react-components/node_modules/@types/istanbul-lib-coverage/index.d.ts
rpt2: /Users/liqing/Desktop/boss-react-components/node_modules/@types/istanbul-lib-report/index.d.ts
rpt2: /Users/liqing/Desktop/boss-react-components/node_modules/@types/istanbul-reports/index.d.ts
rpt2: /Users/liqing/Desktop/boss-react-components/node_modules/@types/jest/ts3.2/index.d.ts
rpt2: /Users/liqing/Desktop/boss-react-components/node_modules/@types/json-schema/index.d.ts
rpt2: /Users/liqing/Desktop/boss-react-components/node_modules/@types/lodash/index.d.ts
rpt2: /Users/liqing/Desktop/boss-react-components/node_modules/@types/minimatch/index.d.ts
rpt2: /Users/liqing/Desktop/boss-react-components/node_modules/@types/minimist/index.d.ts
rpt2: /Users/liqing/Desktop/boss-react-components/node_modules/@types/node/index.d.ts
rpt2: /Users/liqing/Desktop/boss-react-components/node_modules/@types/normalize-package-data/index.d.ts
rpt2: /Users/liqing/Desktop/boss-react-components/node_modules/@types/parse-json/index.d.ts
rpt2: /Users/liqing/Desktop/boss-react-components/node_modules/@types/prettier/index.d.ts
rpt2: /Users/liqing/Desktop/boss-react-components/node_modules/@types/prop-types/index.d.ts
rpt2: /Users/liqing/Desktop/boss-react-components/node_modules/@types/q/index.d.ts
rpt2: /Users/liqing/Desktop/boss-react-components/node_modules/@types/react/index.d.ts
rpt2: /Users/liqing/Desktop/boss-react-components/node_modules/@types/react-dom/index.d.ts
rpt2: /Users/liqing/Desktop/boss-react-components/node_modules/@types/scheduler/index.d.ts
rpt2: /Users/liqing/Desktop/boss-react-components/node_modules/@types/source-list-map/index.d.ts
rpt2: /Users/liqing/Desktop/boss-react-components/node_modules/@types/stack-utils/index.d.ts
rpt2: /Users/liqing/Desktop/boss-react-components/node_modules/@types/tapable/index.d.ts
rpt2: /Users/liqing/Desktop/boss-react-components/node_modules/@types/uglify-js/index.d.ts
rpt2: /Users/liqing/Desktop/boss-react-components/node_modules/@types/webpack/index.d.ts
rpt2: /Users/liqing/Desktop/boss-react-components/node_modules/@types/webpack-sources/index.d.ts
rpt2: /Users/liqing/Desktop/boss-react-components/node_modules/@types/yargs/index.d.ts
rpt2: /Users/liqing/Desktop/boss-react-components/node_modules/@types/yargs-parser/index.d.ts
rpt2: transpiling '/Users/liqing/Desktop/boss-react-components/packages/boss-base-select/src/index.tsx'
rpt2: cache: '/Users/liqing/Desktop/boss-react-components/packages/boss-base-select/node_modules/.cache/rollup-plugin-typescript2/rpt2_d020df83515ced9be6a7e7409761c040b40c97be/code/cache/922d8c7dd9a95c9d547e6a4b9b069a2a69b3e69f'
rpt2: cache hit
rpt2: cache: '/Users/liqing/Desktop/boss-react-components/packages/boss-base-select/node_modules/.cache/rollup-plugin-typescript2/rpt2_d020df83515ced9be6a7e7409761c040b40c97be/syntacticDiagnostics/cache/922d8c7dd9a95c9d547e6a4b9b069a2a69b3e69f'
rpt2: cache hit
rpt2: cache: '/Users/liqing/Desktop/boss-react-components/packages/boss-base-select/node_modules/.cache/rollup-plugin-typescript2/rpt2_d020df83515ced9be6a7e7409761c040b40c97be/semanticDiagnostics/cache/922d8c7dd9a95c9d547e6a4b9b069a2a69b3e69f'
rpt2: cache hit
rpt2: generated declarations for '/Users/liqing/Desktop/boss-react-components/packages/boss-base-select/src/index.tsx'
transforming...
✓ 1 modules transformed.
rendering chunks...
rpt2: generating target 1
rpt2: rolling caches
rpt2: emitting declarations for '/Users/liqing/Desktop/boss-react-components/packages/boss-base-select/src/index.tsx' to '/Users/liqing/Desktop/boss-react-components/packages/boss-base-select/types/index.d.ts'
dist/boss-base-select.cjs.js 2.42kb / brotli: 0.79kb
rpt2: generating target 2
rpt2: rolling caches
rpt2: emitting declarations for '/Users/liqing/Desktop/boss-react-components/packages/boss-base-select/src/index.tsx' to '/Users/liqing/Desktop/boss-react-components/packages/boss-base-select/types/index.d.ts'
dist/boss-base-select.es.js 2.08kb / brotli: 0.66kb
Metadata
Metadata
Assignees
Labels
kind: supportAsking for support with something or a specific use caseAsking for support with something or a specific use caseproblem: no reproNo reproduction was provided (and have not tried to repro without one)No reproduction was provided (and have not tried to repro without one)problem: staleIssue has not been responded to in some timeIssue has not been responded to in some timescope: ViteRelated to integration with Vite, not Rollup, which this plugin was designed forRelated to integration with Vite, not Rollup, which this plugin was designed forscope: integrationRelated to an integration, not necessarily to core (but could influence core)Related to an integration, not necessarily to core (but could influence core)solution: invalidThis doesn't seem rightThis doesn't seem rightsolution: unresolvedIssue has been closed by OP but root cause has not necessarily been resolvedIssue has been closed by OP but root cause has not necessarily been resolvedsolution: workaround availableThere is a workaround available for this issueThere is a workaround available for this issuetopic: monorepo / symlinksRelated to monorepos and/or symlinks (Lerna, Yarn, PNPM, Rush, etc)Related to monorepos and/or symlinks (Lerna, Yarn, PNPM, Rush, etc)