-
-
Notifications
You must be signed in to change notification settings - Fork 483
Closed
Labels
bugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomersgood reproduction ✨This issue provides a good reproduction, we will be able to investigate it firstThis issue provides a good reproduction, we will be able to investigate it first
Description
We are using version 2.0.11. The command we run is vue-tsc --declaration --emitDeclarationOnly
.
Types are generated correctly. However, one file contains additional types:
`export declare const __VLS_globalTypesStart: {};` ... `export declare const __VLS_globalTypesEnd: {};`
} : N2 extends keyof __VLS_GlobalComponents ? N2 extends N0 ? Pick<__VLS_GlobalComponents, N0 extends keyof __VLS_GlobalComponents ? N0 : never> : {
[K in N0]: __VLS_GlobalComponents[N2];
} : N3 extends keyof __VLS_GlobalComponents ? N3 extends N0 ? Pick<__VLS_GlobalComponents, N0 extends keyof __VLS_GlobalComponents ? N0 : never> : {
[K in N0]: __VLS_GlobalComponents[N3];
} : {
[K in N0]: unknown;
};
type __VLS_FillingEventArg_ParametersLength<E extends (...args: any) => any> = __VLS_IsAny<Parameters<E>> extends true ? -1 : Parameters<E>['length'];
type __VLS_FillingEventArg<E> = E extends (...args: any) => any ? __VLS_FillingEventArg_ParametersLength<E> extends 0 ? ($event?: undefined) => ReturnType<E> : E : E;
function __VLS_asFunctionalComponent<T, K = T extends new (...args: any) => any ? InstanceType<T> : unknown>(t: T, instance?: K): T extends new (...args: any) => any ? (props: (K extends {
$props: infer Props;
} ? Props : any) & Record<string, unknown>, ctx?: any) => __VLS_Element & {
__ctx?: {
attrs?: any;
slots?: K extends {
$slots: infer Slots;
} ? Slots : any;
emit?: K extends {
$emit: infer Emit;
} ? Emit : any;
} & {
props?: (K extends {
$props: infer Props;
} ? Props : any) & Record<string, unknown>;
expose?(exposed: K): void;
};
} : T extends () => any ? (props: {}, ctx?: any) => ReturnType<T> : T extends (...args: any) => any ? T : (_: {} & Record<string, unknown>, ctx?: any) => {
__ctx?: {
attrs?: any;
expose?: any;
slots?: any;
emit?: any;
props?: {} & Record<string, unknown>;
};
};
function __VLS_elementAsFunctionalComponent<T>(t: T): (_: T & Record<string, unknown>, ctx?: any) => {
__ctx?: {
attrs?: any;
expose?: any;
slots?: any;
emit?: any;
props?: T & Record<string, unknown>;
};
};
function __VLS_functionalComponentArgsRest<T extends (...args: any) => any>(t: T): Parameters<T>['length'] extends 2 ? [any] : [];
function __VLS_pickEvent<E1, E2>(emitEvent: E1, propEvent: E2): __VLS_FillingEventArg<__VLS_PickNotAny<__VLS_AsFunctionOrAny<E2>, __VLS_AsFunctionOrAny<E1>>> | undefined;
function __VLS_pickFunctionalComponentCtx<T, K>(comp: T, compInstance: K): __VLS_PickNotAny<'__ctx' extends keyof __VLS_PickNotAny<K, {}> ? K extends {
__ctx?: infer Ctx;
} ? Ctx : never : any, T extends (props: any, ctx: infer Ctx) => any ? Ctx : any>;
type __VLS_FunctionalComponentProps<T, K> = '__ctx' extends keyof __VLS_PickNotAny<K, {}> ? K extends {
__ctx?: {
props?: infer P;
};
} ? NonNullable<P> : never : T extends (props: infer P, ...args: any) => any ? P : {};
type __VLS_AsFunctionOrAny<F> = unknown extends F ? any : ((...args: any) => any) extends F ? F : any;
function __VLS_normalizeSlot<S>(s: S): S extends () => infer R ? (props: {}) => R : S;
/**
* emit
*/
type __VLS_UnionToIntersection<U> = (U extends unknown ? (arg: U) => unknown : never) extends ((arg: infer P) => unknown) ? P : never;
type __VLS_OverloadUnionInner<T, U = unknown> = U & T extends (...args: infer A) => infer R ? U extends T ? never : __VLS_OverloadUnionInner<T, Pick<T, keyof T> & U & ((...args: A) => R)> | ((...args: A) => R) : never;
type __VLS_OverloadUnion<T> = Exclude<__VLS_OverloadUnionInner<(() => never) & T>, T extends () => never ? never : () => never>;
type __VLS_ConstructorOverloads<T> = __VLS_OverloadUnion<T> extends infer F ? F extends (event: infer E, ...args: infer A) => any ? {
[K in E & string]: (...args: A) => void;
} : never : never;
type __VLS_NormalizeEmits<T> = __VLS_PrettifyGlobal<__VLS_UnionToIntersection<__VLS_ConstructorOverloads<T> & {
[K in keyof T]: T[K] extends any[] ? {
(...args: T[K]): void;
} : never;
}>>;
type __VLS_PrettifyGlobal<T> = {
[K in keyof T]: T[K];
} & {};
}
I believe these should have been removed by this code.
I cannot upload our code for a reproducer, but maybe it helps to dump the values used in the comparison:
fileName: <pathToRepo>/packages/components/lib/types/components/index-constituents-list/IndexConstituentsList.vue.d.ts
vueLanguagePlugin.getCanonicalFileName(fileName.replace(windowsPathReg, '/')).slice(0, -5): <pathToRepo>/packages/components/lib/types/components/index-constituents-list/indexconstituentslist.vue
vueLanguagePlugin.pluginContext.globalTypesHolder: <pathToRepo>/packages/components/src/components/index-constituents-list/IndexConstituentsList.vue
I think the comparison fails for two reasons:
- The globalTypesHolder has uppercase letters in the filename
- Its comparing the source .vue filename with the filename into which the types are written, which has a different path (we export the types into
dist/types
)
In the end, <pathToRepo>/packages/components/lib/types/components/index-constituents-list/IndexConstituentsList.vue.d.ts
contains the global types.
Here is our tsconfig
tsconfig.json
{
"compilerOptions": {
"target": "es2019",
"module": "esnext",
"declaration": true,
"declarationDir": "./dist/types",
"strict": true,
"jsx": "preserve",
"importHelpers": true,
"moduleResolution": "Bundler",
"experimentalDecorators": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"resolveJsonModule": true,
"baseUrl": ".",
"types": ["node"],
"paths": {
"@/*": ["src/*"]
},
"lib": ["esnext", "dom", "dom.iterable", "scripthost"]
},
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue", "tests/**/*.ts", "tests/**/*.tsx"],
"exclude": ["node_modules"],
"vueCompilerOptions": {
"target": 3
}
}
nandastone
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomersgood reproduction ✨This issue provides a good reproduction, we will be able to investigate it firstThis issue provides a good reproduction, we will be able to investigate it first