rename interfcace, rename file, better generic names, never instead of unknown

pull/6770/head
Simon 4 years ago
parent 5902668254
commit 13cc53cdc3

@ -10,4 +10,4 @@ execSync('tsc -p src/compiler --emitDeclarationOnly && tsc -p src/runtime --emit
// We can't use `export type` syntax either because the TS version we're on doesn't have this feature yet.
const path = 'types/runtime/index.d.ts';
const content = readFileSync(path, 'utf8');
writeFileSync(path, content.replace('SvelteComponentTyped', 'SvelteComponentTyped, ComponentType, ComponentConstructorParams, ComponentProps'));
writeFileSync(path, content.replace('SvelteComponentTyped', 'SvelteComponentTyped, ComponentType, ComponentConstructorOptions, ComponentProps'));

@ -95,7 +95,7 @@
"pretest": "npm run build",
"posttest": "agadoo internal/index.mjs",
"prepublishOnly": "node check_publish_env.js && npm run lint && npm test",
"tsd": "node ./tsd.js",
"tsd": "node ./generate-type-definitions.js",
"lint": "eslint \"{src,test}/**/*.{ts,js}\""
},
"repository": {

@ -128,7 +128,7 @@ export interface SvelteComponentDev {
$destroy(): void;
[accessor: string]: any;
}
export interface ComponentConstructorParams<Props extends Record<string, any> = Record<string, any>> {
export interface ComponentConstructorOptions<Props extends Record<string, any> = Record<string, any>> {
target: Element | ShadowRoot;
anchor?: Element;
props?: Props;
@ -164,7 +164,7 @@ export class SvelteComponentDev extends SvelteComponent {
*/
$$slot_def: any;
constructor(options: ComponentConstructorParams) {
constructor(options: ComponentConstructorOptions) {
if (!options || (!options.target && !options.$$inline)) {
throw new Error("'target' is a required option");
}
@ -256,7 +256,7 @@ export class SvelteComponentTyped<
*/
$$slot_def: Slots;
constructor(options: ComponentConstructorParams<Props>) {
constructor(options: ComponentConstructorOptions<Props>) {
super(options);
}
}
@ -280,8 +280,8 @@ export class SvelteComponentTyped<
* <svelte:element this={componentOfCertainSubType} needsThisProp="hello" />
* ```
*/
export type ComponentType<T extends SvelteComponentTyped = SvelteComponentTyped<any, any, any>> =
new (p: ComponentConstructorParams<T extends SvelteComponentTyped<infer X, any, any> ? X : any>) => T;
export type ComponentType<Component extends SvelteComponentTyped = SvelteComponentTyped<any, any, any>> =
new (p: ComponentConstructorOptions<Component extends SvelteComponentTyped<infer Props, any, any> ? Props : any>) => Component;
/**
* Convenience type to get the properties the given component expects. Example:
@ -294,9 +294,9 @@ export type ComponentType<T extends SvelteComponentTyped = SvelteComponentTyped<
* </script>
* ```
*/
export type ComponentProps<T extends SvelteComponent> = T extends SvelteComponentTyped<infer Props>
export type ComponentProps<Component extends SvelteComponent> = Component extends SvelteComponentTyped<infer Props>
? Props
: unknown;
: never;
export function loop_guard(timeout) {
const start = Date.now();

Loading…
Cancel
Save