ts6 tweaks

This commit is contained in:
Alexander Rose
2026-05-03 00:12:36 -07:00
parent 3ad355ad40
commit cccaa48589
8 changed files with 22 additions and 18 deletions

View File

@@ -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);
}

View File

@@ -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
}

View File

@@ -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);
}
}

View File

@@ -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);

View File

@@ -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<SliderBaseProps, SliderBaseState
const defaultValue = ('defaultValue' in props ? props.defaultValue : initialValue);
const value = (props.value !== undefined ? props.value : defaultValue);
// @ts-ignore
const bounds = (range ? value : [min, value]).map((v: number) => this.trimAlignValue(v));
let recent;

View File

@@ -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<string>(['0'], PD.arrayToOptions(['0']), {
isEssential: true
})
)

View File

@@ -234,12 +234,14 @@ export namespace MonadicParser {
export type Result<T> = Success<T> | Failure
export function seqMap<A, B>(a: MonadicParser<A>, b: MonadicParser<B>, 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<any> {
return obj instanceof MonadicParser;
}
function assertFunction(x: any) {
if (typeof x !== 'function') {
throw new Error('not a function: ' + x);
}
}

View File

@@ -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/*" ],