Waaaaay stricter types, and then fix bad types, whoohoooo

This commit is contained in:
Norbert de Langen 2022-01-28 21:58:47 +01:00
parent eeb99087e5
commit 9fdc75fb74
No known key found for this signature in database
GPG Key ID: FD0E78AF9A837762
31 changed files with 256 additions and 714 deletions

View File

@ -133,7 +133,6 @@
"rxjs": "^6.6.3",
"styled-components": "^5.2.1",
"sveltedoc-parser": "4.1.0",
"terser-webpack-plugin": "^5.0.3",
"tmp": "^0.2.1",
"tslib": "^2.1.0",
"vue": "^2.6.10",

View File

@ -2,6 +2,7 @@
"extends": "../../tsconfig.json",
"compilerOptions": {
"rootDir": "./src",
"skipLibCheck": true,
"types": [
"webpack-env",
"jest",

View File

@ -6,6 +6,7 @@
"compilerOptions": {
"rootDir": "./src",
"experimentalDecorators": true,
"declaration": true
"declaration": true,
"skipLibCheck": true
}
}

View File

@ -2,6 +2,7 @@
"extends": "../../../tsconfig.json",
"compilerOptions": {
"rootDir": "./src",
"skipLibCheck": true,
"types": [
"webpack-env",
"node"

View File

@ -1,7 +1,5 @@
import { CLIOptions, LoadOptions, BuilderOptions } from '@storybook/core-common';
import { BuilderContext } from '@angular-devkit/architect';
import { JsonValue } from '@angular-devkit/core';
import { JsonSchema } from '@angular-devkit/core/src/json/schema';
export type StandaloneOptions = Partial<
CLIOptions &
@ -9,9 +7,9 @@ export type StandaloneOptions = Partial<
BuilderOptions & {
mode?: 'static' | 'dev';
angularBrowserTarget?: string | null;
angularBuilderOptions?: JsonObject & {
styles?: ExtraEntryPoint[];
stylePreprocessorOptions?: StylePreprocessorOptions;
angularBuilderOptions?: Record<string, any> & {
styles?: any[];
stylePreprocessorOptions?: any;
};
angularBuilderContext?: BuilderContext | null;
tsConfig?: string;

View File

@ -8,6 +8,7 @@
"node"
],
"rootDir": "./src",
"skipLibCheck": true,
"resolveJsonModule": true,
"allowJs": true
},

View File

@ -1,5 +1,5 @@
declare module 'global';
declare module 'vue-loader' {
export const VueLoaderPlugin
export const VueLoaderPlugin: any
}

View File

@ -6,7 +6,8 @@
"webpack-env",
"node"
],
"resolveJsonModule": true
"resolveJsonModule": true,
"skipLibCheck": true
},
"include": [
"src/**/*"

View File

@ -111,7 +111,7 @@
},
"devDependencies": {
"@types/case-sensitive-paths-webpack-plugin": "^2.1.4",
"@types/terser-webpack-plugin": "^5.0.2",
"@types/terser-webpack-plugin": "^4.2.0",
"@types/webpack-dev-middleware": "^3.7.3",
"@types/webpack-hot-middleware": "^2.25.3",
"@types/webpack-virtual-modules": "^0.1.0"

View File

@ -83,7 +83,7 @@
"@types/shelljs": "^0.8.7",
"@types/update-notifier": "^5.0.0",
"strip-json-comments": "^3.1.1",
"update-notifier": "^4.1.3"
"update-notifier": "^5.0.1"
},
"peerDependencies": {
"jest": "*"

View File

@ -1,7 +1,8 @@
import { StoryStore } from '@storybook/client-api';
import type { AnyFramework } from '@storybook/csf';
import type { StoryStore } from '@storybook/client-api';
declare global {
interface Window {
__STORYBOOK_STORY_STORE__: StoryStore;
__STORYBOOK_STORY_STORE__: StoryStore<AnyFramework>;
}
}

View File

@ -10,29 +10,3 @@ declare module 'open';
declare module 'x-default-browser';
declare module '@storybook/ui';
declare module 'file-system-cache' {
export interface Options {
basePath?: string;
ns?: string | string[];
extension?: string;
}
export declare class FileSystemCache {
constructor(options: Options);
path(key: string): string;
fileExists(key: string): Promise<boolean>;
ensureBasePath(): Promise<void>;
get(key: string, defaultValue?: any): Promise<any | typeof defaultValue>;
getSync(key: string, defaultValue?: any): any | typeof defaultValue;
set(key: string, value: any): Promise<{ path: string }>;
setSync(key: string, value: any): this;
remove(key: string): Promise<void>;
clear(): Promise<void>;
save(): Promise<{ paths: string[] }>;
load(): Promise<{ files: Array<{ path: string; value: any }> }>;
}
function create(options: Options): FileSystemCache;
export = create;
}

View File

@ -29,3 +29,5 @@ export * from './utils/readTemplate';
export * from './utils/findDistEsm';
export * from './types';
export { createFileSystemCache } from './utils/file-cache';

View File

@ -4,8 +4,8 @@ import type { PluginOptions } from '@storybook/react-docgen-typescript-plugin';
import { Configuration, Stats } from 'webpack';
import { TransformOptions } from '@babel/core';
import { Router } from 'express';
import { FileSystemCache } from 'file-system-cache';
import { Server } from 'http';
import { FileSystemCache } from './utils/file-cache';
/**
* This file contains internal WIP types they MUST NOT be exported outside this package for now!

11
lib/core-common/src/typings.d.ts vendored Normal file
View File

@ -0,0 +1,11 @@
/// <reference types="@types/compression" />
declare module 'lazy-universal-dotenv';
declare module 'pnp-webpack-plugin';
declare module '@storybook/semver';
declare namespace jest {
interface Matchers<R> {
toMatchPaths(paths: string[]): R;
}
}

View File

@ -1,7 +1,7 @@
import Cache from 'file-system-cache';
import { createFileSystemCache } from './file-cache';
import { resolvePathInStorybookCache } from './resolve-path-in-sb-cache';
export const cache = Cache({
export const cache = createFileSystemCache({
basePath: resolvePathInStorybookCache('dev-server'),
ns: 'storybook', // Optional. A grouping namespace for items.
});

View File

@ -0,0 +1,65 @@
// @ts-ignore - this package has no typings, so we wrap it and add typings that way, because we expose it
import Cache from 'file-system-cache';
export interface Options {
basePath?: string;
ns?: string | string[];
extension?: string;
}
export class FileSystemCache {
constructor(options: Options) {
this.internal = Cache(options) as any as FileSystemCache;
}
private internal: FileSystemCache;
path(key: string): string {
return this.internal.path(key);
}
fileExists(key: string): Promise<boolean> {
return this.internal.fileExists(key);
}
ensureBasePath(): Promise<void> {
return this.internal.ensureBasePath();
}
get(key: string, defaultValue?: any): Promise<any | typeof defaultValue> {
return this.internal.get(key, defaultValue);
}
getSync(key: string, defaultValue?: any): any | typeof defaultValue {
this.internal.getSync(key, defaultValue);
}
set(key: string, value: any): Promise<{ path: string }> {
return this.internal.set(key, value);
}
setSync(key: string, value: any): this {
this.internal.setSync(key, value);
return this;
}
remove(key: string): Promise<void> {
return this.internal.remove(key);
}
clear(): Promise<void> {
return this.internal.clear();
}
save(): Promise<{ paths: string[] }> {
return this.internal.save();
}
load(): Promise<{ files: Array<{ path: string; value: any }> }> {
return this.internal.load();
}
}
export function createFileSystemCache(options: Options): FileSystemCache {
return new FileSystemCache(options);
}

View File

@ -8,8 +8,7 @@
]
},
"include": [
"src/**/*",
"typings.d.ts"
"src/**/*"
],
"exclude": [
"src/**.test.ts"

View File

@ -1,38 +0,0 @@
import('@types/compression');
declare module 'lazy-universal-dotenv';
declare module 'pnp-webpack-plugin';
declare module '@storybook/semver';
declare namespace jest {
interface Matchers<R> {
toMatchPaths(paths: string[]): R;
}
}
declare module 'file-system-cache' {
export interface Options {
basePath?: string;
ns?: string | string[];
extension?: string;
}
export declare class FileSystemCache {
constructor(options: Options);
path(key: string): string;
fileExists(key: string): Promise<boolean>;
ensureBasePath(): Promise<void>;
get(key: string, defaultValue?: any): Promise<any | typeof defaultValue>;
getSync(key: string, defaultValue?: any): any | typeof defaultValue;
set(key: string, value: any): Promise<{ path: string }>;
setSync(key: string, value: any): this;
remove(key: string): Promise<void>;
clear(): Promise<void>;
save(): Promise<{ paths: string[] }>;
load(): Promise<{ files: Array<{ path: string; value: any }> }>;
}
function create(options: Options): FileSystemCache;
export = create;
}

View File

@ -64,7 +64,6 @@
"cpy": "^8.1.2",
"detect-port": "^1.3.0",
"express": "^4.17.1",
"file-system-cache": "^1.0.5",
"fs-extra": "^9.0.1",
"globby": "^11.0.2",
"ip": "^1.1.5",

View File

@ -4,8 +4,7 @@ import { mkdtemp as mkdtempCb } from 'fs';
import os from 'os';
import { promisify } from 'util';
import { Configuration } from 'webpack';
import Cache from 'file-system-cache';
import { resolvePathInStorybookCache } from '@storybook/core-common';
import { resolvePathInStorybookCache, createFileSystemCache } from '@storybook/core-common';
import { executor as previewExecutor } from '@storybook/builder-webpack4';
import { executor as managerExecutor } from '@storybook/manager-webpack4';
@ -79,7 +78,7 @@ jest.mock('./utils/output-startup-information', () => ({
jest.mock('./utils/output-stats');
const cache = Cache({
const cache = createFileSystemCache({
basePath: resolvePathInStorybookCache('dev-server'),
ns: 'storybook-test', // Optional. A grouping namespace for items.
});

View File

@ -12,29 +12,3 @@ declare module '@storybook/ui';
declare module '@discoveryjs/json-ext';
declare module 'watchpack';
declare module 'file-system-cache' {
export interface Options {
basePath?: string;
ns?: string | string[];
extension?: string;
}
export declare class FileSystemCache {
constructor(options: Options);
path(key: string): string;
fileExists(key: string): Promise<boolean>;
ensureBasePath(): Promise<void>;
get(key: string, defaultValue?: any): Promise<any | typeof defaultValue>;
getSync(key: string, defaultValue?: any): any | typeof defaultValue;
set(key: string, value: any): Promise<{ path: string }>;
setSync(key: string, value: any): this;
remove(key: string): Promise<void>;
clear(): Promise<void>;
save(): Promise<{ paths: string[] }>;
load(): Promise<{ files: Array<{ path: string; value: any }> }>;
}
function create(options: Options): FileSystemCache;
export = create;
}

View File

@ -60,7 +60,6 @@
"css-loader": "^3.6.0",
"express": "^4.17.1",
"file-loader": "^6.2.0",
"file-system-cache": "^1.0.5",
"find-up": "^5.0.0",
"fs-extra": "^9.0.1",
"html-webpack-plugin": "^4.0.0",
@ -81,7 +80,7 @@
},
"devDependencies": {
"@types/case-sensitive-paths-webpack-plugin": "^2.1.4",
"@types/terser-webpack-plugin": "^5.0.2",
"@types/terser-webpack-plugin": "^4.2.0",
"@types/webpack-dev-middleware": "^3.7.3",
"@types/webpack-virtual-modules": "^0.1.0"
},

View File

@ -9,30 +9,3 @@ declare module 'better-opn';
declare module 'open';
declare module 'x-default-browser';
declare module '@storybook/ui';
declare module 'file-system-cache' {
export interface Options {
basePath?: string;
ns?: string | string[];
extension?: string;
}
export declare class FileSystemCache {
constructor(options: Options);
path(key: string): string;
fileExists(key: string): Promise<boolean>;
ensureBasePath(): Promise<void>;
get(key: string, defaultValue?: any): Promise<any | typeof defaultValue>;
getSync(key: string, defaultValue?: any): any | typeof defaultValue;
set(key: string, value: any): Promise<{ path: string }>
setSync(key: string, value: any): this;
remove(key: string): Promise<void>;
clear(): Promise<void>;
save(): Promise<{ paths: string[] }>;
load(): Promise<{ files: Array<{ path: string, value: any }> }>;
}
function create(options: Options): FileSystemCache;
export = create;
}

View File

@ -58,7 +58,6 @@
"core-js": "^3.8.2",
"css-loader": "^5.0.1",
"express": "^4.17.1",
"file-system-cache": "^1.0.5",
"find-up": "^5.0.0",
"fs-extra": "^9.0.1",
"html-webpack-plugin": "^5.0.0",

View File

@ -8,30 +8,3 @@ declare module 'better-opn';
declare module 'open';
declare module 'x-default-browser';
declare module '@storybook/ui';
declare module 'file-system-cache' {
export interface Options {
basePath?: string;
ns?: string | string[];
extension?: string;
}
export declare class FileSystemCache {
constructor(options: Options);
path(key: string): string;
fileExists(key: string): Promise<boolean>;
ensureBasePath(): Promise<void>;
get(key: string, defaultValue?: any): Promise<any | typeof defaultValue>;
getSync(key: string, defaultValue?: any): any | typeof defaultValue;
set(key: string, value: any): Promise<{ path: string }>;
setSync(key: string, value: any): this;
remove(key: string): Promise<void>;
clear(): Promise<void>;
save(): Promise<{ paths: string[] }>;
load(): Promise<{ files: Array<{ path: string; value: any }> }>;
}
function create(options: Options): FileSystemCache;
export = create;
}

View File

@ -1,7 +1,10 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"rootDir": "./src"
"rootDir": "./src",
"types": [
"node"
]
},
"include": [
"src/**/*"

View File

@ -4,4 +4,4 @@ import { transform } from './build';
export * from './types';
export * from './extract-source';
export default transform;
export default transform as any;

View File

@ -98,6 +98,8 @@
"defaults"
],
"resolutions": {
"boxen": "^5.1.2",
"eslint": "^7.17.0",
"serialize-javascript": "^3.1.0"
},
"devDependencies": {
@ -205,6 +207,7 @@
"@types/semver": "^7.3.4",
"@types/serve-static": "^1.13.8",
"@types/shelljs": "^0.8.7",
"@types/terser-webpack-plugin": "^4.2.0",
"@types/webpack-dev-middleware": "^3.7.3",
"@types/webpack-env": "^1.16.0",
"babel-core": "^7.0.0-bridge.0",
@ -283,6 +286,7 @@
"shx": "^0.3.2",
"sort-package-json": "^1.48.1",
"teamcity-service-messages": "^0.1.11",
"terser-webpack-plugin": "^4.2.3",
"trash": "^7.0.0",
"ts-dedent": "^2.0.0",
"ts-jest": "^26.4.4",

View File

@ -9,7 +9,7 @@
"jsx": "react",
"moduleResolution": "Node",
"module": "CommonJS",
"skipLibCheck": true,
"skipLibCheck": false,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"isolatedModules": true,

687
yarn.lock

File diff suppressed because it is too large Load Diff