chore: remove experimental decorators from the repo (#31487)

This commit is contained in:
Bill Glesias
2025-04-14 15:07:11 -04:00
committed by GitHub
parent ed796256e2
commit 189bb9ee5f
12 changed files with 119 additions and 136 deletions
-1
View File
@@ -43,7 +43,6 @@
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
"esModuleInterop": true
},
-1
View File
@@ -42,7 +42,6 @@
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
"esModuleInterop": true,
/** Allows us to strip internal types sourced from webpack */
@@ -42,7 +42,6 @@
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
"esModuleInterop": true,
/** Allows us to strip internal types sourced from webpack */
-1
View File
@@ -45,7 +45,6 @@
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
"esModuleInterop": true
},
-1
View File
@@ -42,7 +42,6 @@
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
"esModuleInterop": true,
"skipLibCheck": true,
-1
View File
@@ -56,7 +56,6 @@
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
/* Advanced Options */
+57 -38
View File
@@ -19,98 +19,117 @@ import { ErrorActions } from './actions/ErrorActions'
import { EventCollectorActions } from './actions/EventCollectorActions'
import { NotificationActions } from './actions/NotificationActions'
import { VersionsActions } from './actions/VersionsActions'
import { cached } from './util'
export class DataActions {
constructor (private ctx: DataContext) {}
private _error: ErrorActions
private _file: FileActions
private _dev: DevActions
private _app: AppActions
private _auth: AuthActions
private _localSettings: LocalSettingsActions
private _wizard: WizardActions
private _project: ProjectActions
private _electron: ElectronActions
private _migration: MigrationActions
private _browser: BrowserActions
private _servers: ServersActions
private _versions: VersionsActions
private _eventCollector: EventCollectorActions
private _cohorts: CohortsActions
private _codegen: CodegenActions
private _notification: NotificationActions
private _cloudProject: CloudProjectActions
constructor (private ctx: DataContext) {
this._error = new ErrorActions(this.ctx)
this._file = new FileActions(this.ctx)
this._dev = new DevActions(this.ctx)
this._app = new AppActions(this.ctx)
this._auth = new AuthActions(this.ctx)
this._localSettings = new LocalSettingsActions(this.ctx)
this._wizard = new WizardActions(this.ctx)
this._project = new ProjectActions(this.ctx)
this._electron = new ElectronActions(this.ctx)
this._migration = new MigrationActions(this.ctx)
this._browser = new BrowserActions(this.ctx)
this._servers = new ServersActions(this.ctx)
this._versions = new VersionsActions(this.ctx)
this._eventCollector = new EventCollectorActions(this.ctx)
this._cohorts = new CohortsActions(this.ctx)
this._codegen = new CodegenActions(this.ctx)
this._notification = new NotificationActions(this.ctx)
this._cloudProject = new CloudProjectActions(this.ctx)
}
@cached
get error () {
return new ErrorActions(this.ctx)
return this._error
}
@cached
get file () {
return new FileActions(this.ctx)
return this._file
}
@cached
get dev () {
return new DevActions(this.ctx)
return this._dev
}
@cached
get app () {
return new AppActions(this.ctx)
return this._app
}
@cached
get auth () {
return new AuthActions(this.ctx)
return this._auth
}
@cached
get localSettings () {
return new LocalSettingsActions(this.ctx)
return this._localSettings
}
@cached
get wizard () {
return new WizardActions(this.ctx)
return this._wizard
}
@cached
get project () {
return new ProjectActions(this.ctx)
return this._project
}
@cached
get electron () {
return new ElectronActions(this.ctx)
return this._electron
}
@cached
get migration () {
return new MigrationActions(this.ctx)
return this._migration
}
@cached
get browser () {
return new BrowserActions(this.ctx)
return this._browser
}
@cached
get servers () {
return new ServersActions(this.ctx)
return this._servers
}
@cached
get versions () {
return new VersionsActions(this.ctx)
return this._versions
}
@cached
get eventCollector () {
return new EventCollectorActions(this.ctx)
return this._eventCollector
}
@cached
get cohorts () {
return new CohortsActions(this.ctx)
return this._cohorts
}
@cached
get codegen () {
return new CodegenActions(this.ctx)
return this._codegen
}
@cached
get notification () {
return new NotificationActions(this.ctx)
return this._notification
}
@cached
get cloudProject () {
return new CloudProjectActions(this.ctx)
return this._cloudProject
}
}
+62 -46
View File
@@ -33,7 +33,6 @@ import {
GraphQLDataSource,
RemoteRequestDataSource,
} from './sources'
import { cached } from './util/cached'
import type { GraphQLSchema, OperationTypeNode, DocumentNode } from 'graphql'
import type { IncomingHttpHeaders } from 'http'
// tslint:disable-next-line no-implicit-dependencies - electron dep needs to be defined
@@ -86,6 +85,24 @@ export class DataContext {
private _config: Omit<DataContextConfig, 'modeOptions'>
private _modeOptions: Partial<AllModeOptions>
private _coreData: CoreDataShape
private _graphql: GraphQLDataSource
private _remoteRequest: RemoteRequestDataSource
private _file: FileDataSource
private _versions: VersionsDataSource
private _browser: BrowserDataSource
private _actions: DataActions
private _wizard: WizardDataSource
private _project: ProjectDataSource
private _relevantRuns: RelevantRunsDataSource
private _relevantRunSpecs: RelevantRunSpecsDataSource
private _cloud: CloudDataSource
private _env: EnvDataSource
private _emitter: DataEmitterActions
private _html: HtmlDataSource
private _error: ErrorDataSource
private _util: UtilDataSource
private _migration: MigrationDataSource
readonly lifecycleManager: ProjectLifecycleManager
constructor (_config: DataContextConfig) {
@@ -94,6 +111,33 @@ export class DataContext {
this._config = rest
this._modeOptions = modeOptions ?? {} // {} For legacy tests
this._coreData = _config.coreData ?? makeCoreData(this._modeOptions)
this._graphql = new GraphQLDataSource()
this._remoteRequest = new RemoteRequestDataSource()
this._file = new FileDataSource(this)
this._versions = new VersionsDataSource(this)
this._browser = new BrowserDataSource(this)
this._actions = new DataActions(this)
this._wizard = new WizardDataSource(this)
this._project = new ProjectDataSource(this)
this._relevantRuns = new RelevantRunsDataSource(this)
this._relevantRunSpecs = new RelevantRunSpecsDataSource(this)
this._cloud = new CloudDataSource({
fetch: (input: RequestInfo | URL, init?: RequestInit) => this.util.fetch(input, init),
getUser: () => this.coreData.user,
logout: () => this.actions.auth.logout().catch(this.logTraceError),
invalidateClientUrqlCache: () => this.graphql.invalidateClientUrqlCache(this),
headers: {
getMachineId: this.coreData.machineId,
},
})
this._env = new EnvDataSource(this)
this._emitter = new DataEmitterActions(this)
this._html = new HtmlDataSource(this)
this._error = new ErrorDataSource(this)
this._util = new UtilDataSource(this)
this._migration = new MigrationDataSource(this)
// the lifecycle manager needs to be initialized last as it needs properties instantiated on the DataContext object
this.lifecycleManager = new ProjectLifecycleManager(this)
}
@@ -113,14 +157,12 @@ export class DataContext {
return !this.isRunMode
}
@cached
get graphql () {
return new GraphQLDataSource()
return this._graphql
}
@cached
get remoteRequest () {
return new RemoteRequestDataSource()
return this._remoteRequest
}
get modeOptions (): Readonly<Partial<AllModeOptions>> {
@@ -131,95 +173,71 @@ export class DataContext {
return this._coreData
}
@cached
get file () {
return new FileDataSource(this)
return this._file
}
@cached
get versions () {
return new VersionsDataSource(this)
return this._versions
}
@cached
get browser () {
return new BrowserDataSource(this)
return this._browser
}
/**
* All mutations (update / delete / create), fs writes, etc.
* should run through this namespace. Everything else should be a "getter"
*/
@cached
get actions () {
return new DataActions(this)
return this._actions
}
@cached
get wizard () {
return new WizardDataSource(this)
return this._wizard
}
get currentProject () {
return this.coreData.currentProject
}
@cached
get project () {
return new ProjectDataSource(this)
return this._project
}
@cached
get relevantRuns () {
return new RelevantRunsDataSource(this)
return this._relevantRuns
}
@cached
get relevantRunSpecs () {
return new RelevantRunSpecsDataSource(this)
return this._relevantRunSpecs
}
@cached
get cloud () {
return new CloudDataSource({
fetch: (input: RequestInfo | URL, init?: RequestInit) => this.util.fetch(input, init),
getUser: () => this.coreData.user,
logout: () => this.actions.auth.logout().catch(this.logTraceError),
invalidateClientUrqlCache: () => this.graphql.invalidateClientUrqlCache(this),
headers: {
getMachineId: this.coreData.machineId,
},
})
return this._cloud
}
@cached
get env () {
return new EnvDataSource(this)
return this._env
}
@cached
get emitter () {
return new DataEmitterActions(this)
return this._emitter
}
@cached
get html () {
return new HtmlDataSource(this)
return this._html
}
@cached
get error () {
return new ErrorDataSource(this)
return this._error
}
@cached
get util () {
return new UtilDataSource(this)
return this._util
}
@cached
get migration () {
return new MigrationDataSource(this)
return this._migration
}
/**
@@ -231,12 +249,10 @@ export class DataContext {
// Utilities
@cached
get fs () {
return fsExtra
}
@cached
get path () {
return path
}
-43
View File
@@ -1,43 +0,0 @@
/**
* A cached decorator means the value is lazily evaluated once and
* the result is cached on the class instance.
*/
export const cached = <T>(
target: T,
key: PropertyKey,
descriptor: PropertyDescriptor,
): void => {
if (!descriptor) {
descriptor = Object.getOwnPropertyDescriptor(
target,
key,
) as PropertyDescriptor
}
const originalMethod = descriptor.get
const isStatic = Object.getPrototypeOf(target) === Function.prototype
if (isStatic) {
throw new Error(`Don't use @cached decorator on static properties`)
}
if (!originalMethod) {
throw new Error('@cached can only decorate getters!')
} else if (!descriptor.configurable) {
throw new Error('@cached target must be configurable')
} else {
descriptor.get = function () {
// eslint-disable-next-line
const value = originalMethod.apply(this, arguments as any)
const newDescriptor: PropertyDescriptor = {
configurable: false,
enumerable: false,
value,
}
Object.defineProperty(this, key, newDescriptor)
return value
}
}
}
-1
View File
@@ -3,7 +3,6 @@
export * from './DocumentNodeBuilder'
export * from './autoBindDebug'
export * from './cached'
export * from './config-file-updater'
export * from './file'
export * from './hasTypescript'
-1
View File
@@ -14,7 +14,6 @@
"target": "ES2018", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
"lib": ["es2021"], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
"jsx": "react", /* Specify what JSX code is generated. */
"experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
-1
View File
@@ -101,7 +101,6 @@ export async function makePackage () {
'outDir': 'dist',
'noImplicitAny': true,
'resolveJsonModule': true,
'experimentalDecorators': true,
'noUncheckedIndexedAccess': true,
'importsNotUsedAsValues': 'error',
'types': [],