From cccaa48589f6afd5e56d187df56cfa135c4a58de Mon Sep 17 00:00:00 2001 From: Alexander Rose Date: Sun, 3 May 2026 00:12:36 -0700 Subject: [PATCH] ts6 tweaks --- src/mol-canvas3d/helper/pointer-helper.ts | 2 +- src/mol-gl/webgl/compat.ts | 4 ++-- src/mol-io/common/binary.ts | 2 ++ src/mol-io/reader/dsn6/parser.ts | 3 ++- src/mol-plugin-ui/controls/slider.tsx | 7 ++++--- src/mol-repr/volume/segment.ts | 2 +- src/mol-util/monadic-parser.ts | 12 ++++-------- tsconfig.json | 8 ++++++-- 8 files changed, 22 insertions(+), 18 deletions(-) diff --git a/src/mol-canvas3d/helper/pointer-helper.ts b/src/mol-canvas3d/helper/pointer-helper.ts index 1dc5fc60f..6c86b7038 100644 --- a/src/mol-canvas3d/helper/pointer-helper.ts +++ b/src/mol-canvas3d/helper/pointer-helper.ts @@ -121,7 +121,7 @@ export class PointerHelper { this.camera = new Camera(); - this.shape = getPointerMeshShape(this.getData(), this.props, this.shape); + this.shape = getPointerMeshShape(this.getData(), this.props); this.renderObject = createMeshRenderObject(this.shape, this.props); this.scene.add(this.renderObject); } diff --git a/src/mol-gl/webgl/compat.ts b/src/mol-gl/webgl/compat.ts index 4af2ee6a7..d249c8a4c 100644 --- a/src/mol-gl/webgl/compat.ts +++ b/src/mol-gl/webgl/compat.ts @@ -104,7 +104,7 @@ export interface COMPAT_vertex_array_object { bindVertexArray(arrayObject: WebGLVertexArrayObject | null): void; createVertexArray(): WebGLVertexArrayObject | null; deleteVertexArray(arrayObject: WebGLVertexArrayObject): void; - isVertexArray(value: any): value is WebGLVertexArrayObject; + isVertexArray(value: any): boolean } export function getVertexArrayObject(gl: GLRenderingContext): COMPAT_vertex_array_object | null { @@ -484,7 +484,7 @@ export interface COMPAT_disjoint_timer_query { /** Records the current time into the corresponding query object. */ queryCounter: (query: WebGLQuery, target: number) => void /** Returns information about a query target. */ - getQuery: (target: number, pname: number) => WebGLQuery | number + getQuery: (target: number, pname: number) => WebGLQuery | null /** Return the state of a query object. */ getQueryParameter: (query: WebGLQuery, pname: number) => number | boolean } diff --git a/src/mol-io/common/binary.ts b/src/mol-io/common/binary.ts index dc2bd28c4..871d3e265 100644 --- a/src/mol-io/common/binary.ts +++ b/src/mol-io/common/binary.ts @@ -23,10 +23,12 @@ export function uint8ToString(array: Uint8Array) { if (array.length > ChunkSize) { const c = []; for (let i = 0; i < array.length; i += ChunkSize) { + // @ts-ignore c.push(String.fromCharCode.apply(null, array.subarray(i, i + ChunkSize))); } return c.join(''); } else { + // @ts-ignore return String.fromCharCode.apply(null, array); } } \ No newline at end of file diff --git a/src/mol-io/reader/dsn6/parser.ts b/src/mol-io/reader/dsn6/parser.ts index 59d081920..056556bf1 100644 --- a/src/mol-io/reader/dsn6/parser.ts +++ b/src/mol-io/reader/dsn6/parser.ts @@ -9,6 +9,7 @@ import { Dsn6File, Dsn6Header } from './schema'; import { ReaderResult as Result } from '../result'; import { FileHandle } from '../../common/file-handle'; import { SimpleBuffer } from '../../../mol-io/common/simple-buffer'; +import { uint8ToString } from '../../common/binary'; export const dsn6HeaderSize = 512; @@ -70,7 +71,7 @@ function getBlocks(header: Dsn6Header) { export async function readDsn6Header(file: FileHandle): Promise<{ header: Dsn6Header, littleEndian: boolean }> { const { buffer } = await file.readBuffer(0, dsn6HeaderSize); - const brixStr = String.fromCharCode.apply(null, buffer) as string; + const brixStr = uint8ToString(buffer); const isBrix = brixStr.startsWith(':-)'); const littleEndian = isBrix || buffer.readInt16LE(18 * 2) === 100; const header = isBrix ? parseBrixHeader(brixStr) : parseDsn6Header(buffer, littleEndian); diff --git a/src/mol-plugin-ui/controls/slider.tsx b/src/mol-plugin-ui/controls/slider.tsx index 325df85c5..cd73696d3 100644 --- a/src/mol-plugin-ui/controls/slider.tsx +++ b/src/mol-plugin-ui/controls/slider.tsx @@ -181,8 +181,8 @@ export class Slider2 extends React.Component<{ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -function classNames(_classes: { [name: string]: boolean | number }) { - const classes = []; +function classNames(_classes: { [name: string]: boolean | number }): string { + const classes: string[] = []; const hasOwn = {}.hasOwnProperty; for (let i = 0; i < arguments.length; i++) { @@ -194,7 +194,7 @@ function classNames(_classes: { [name: string]: boolean | number }) { if (argType === 'string' || argType === 'number') { classes.push(arg); } else if (Array.isArray(arg)) { - classes.push(classNames.apply(null, arg)); + classes.push(classNames.apply(null, arg as any)); } else if (argType === 'object') { for (const key in arg) { if (hasOwn.call(arg, key) && arg[key]) { @@ -290,6 +290,7 @@ export class SliderBase extends React.Component this.trimAlignValue(v)); let recent; diff --git a/src/mol-repr/volume/segment.ts b/src/mol-repr/volume/segment.ts index a3a5deb6f..d6278143e 100644 --- a/src/mol-repr/volume/segment.ts +++ b/src/mol-repr/volume/segment.ts @@ -34,7 +34,7 @@ export const VolumeSegmentParams = { segments: PD.Converted( (v: number[]) => v.map(x => `${x}`), (v: string[]) => v.map(x => parseInt(x)), - PD.MultiSelect(['0'], PD.arrayToOptions(['0']), { + PD.MultiSelect(['0'], PD.arrayToOptions(['0']), { isEssential: true }) ) diff --git a/src/mol-util/monadic-parser.ts b/src/mol-util/monadic-parser.ts index ad96df44c..b1c65d14e 100644 --- a/src/mol-util/monadic-parser.ts +++ b/src/mol-util/monadic-parser.ts @@ -234,12 +234,14 @@ export namespace MonadicParser { export type Result = Success | Failure export function seqMap(a: MonadicParser, b: MonadicParser, c: any) { - const args = [].slice.call(arguments); + const args: any[] = [].slice.call(arguments); if (args.length === 0) { throw new Error('seqMap needs at least one argument'); } const mapper = args.pop(); - assertFunction(mapper); + if (typeof mapper !== 'function') { + throw new Error('not a function: ' + mapper); + } return seq.apply(null, args).map(function (results: any) { return mapper.apply(null, results); }); @@ -571,9 +573,3 @@ function unsafeUnion(xs: string[], ys: string[]) { function isParser(obj: any): obj is MonadicParser { return obj instanceof MonadicParser; } - -function assertFunction(x: any) { - if (typeof x !== 'function') { - throw new Error('not a function: ' + x); - } -} diff --git a/tsconfig.json b/tsconfig.json index 615b194bb..eb3dc0cb4 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,7 +11,7 @@ "strictFunctionTypes": true, "module": "esnext", "esModuleInterop": true, - "moduleResolution": "node", + "moduleResolution": "bundler", "isolatedModules": true, "importHelpers": true, "noEmitHelpers": true, @@ -19,7 +19,11 @@ "jsx": "react-jsx", "lib": [ "ES2018", "dom", "ES2022.Object" ], "rootDir": "src", - "outDir": "lib" + "outDir": "lib", + "noUncheckedSideEffectImports": false, + "useUnknownInCatchVariables": false, + "strictPropertyInitialization": false, + "types": ["webxr", "node"] }, "include": [ "src/**/*" ], "exclude": [ "src/**/_spec/*" ],